From 1c78505f7c650f3bdfbbf21d6f25bc8d59394307 Mon Sep 17 00:00:00 2001 From: Seth Axen Date: Thu, 30 Dec 2021 18:22:25 +0100 Subject: [PATCH 1/4] Deprecate sorted keyword --- src/core.jl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/core.jl b/src/core.jl index 04e42fd0..e46f1f44 100644 --- a/src/core.jl +++ b/src/core.jl @@ -170,8 +170,6 @@ While `psis` computes smoothed log weights out-of-place, `psis!` smooths them in # Keywords - - `sorted=issorted(vec(log_ratios))`: whether `log_ratios` are already sorted. Only - accepted if `nparams==1`. - `improved=false`: If `true`, use the adaptive empirical prior of [^Zhang2010]. If `false`, use the simpler prior of [^ZhangStephens2009], which is also used in [^VehtariSimpson2021]. @@ -207,7 +205,7 @@ end function psis!( logw::AbstractVector, reff=1; - sorted::Bool=issorted(logw), + sorted::Bool=false, # deprecated improved::Bool=false, warn::Bool=true, ) From 865ab6bb46340fdceb74d2ab2354b8a0a9bab95d Mon Sep 17 00:00:00 2001 From: Seth Axen Date: Thu, 30 Dec 2021 18:22:38 +0100 Subject: [PATCH 2/4] Use partialsortperm --- src/core.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core.jl b/src/core.jl index e46f1f44..c21dc01b 100644 --- a/src/core.jl +++ b/src/core.jl @@ -217,11 +217,11 @@ function psis!( @warn "$M tail draws is insufficient to fit the generalized Pareto distribution. $MISSING_SHAPE_SUMMARY" return PSISResult(logw, LogExpFunctions.logsumexp(logw), reff_val, M, missing) end - perm = sorted ? collect(eachindex(logw)) : sortperm(logw) - icut = S - M - tail_range = (icut + 1):S - @inbounds logw_tail = @views logw[perm[tail_range]] - @inbounds logu = logw[perm[icut]] + perm = partialsortperm(logw, (S - M):S) + cutoff_ind = perm[1] + tail_inds = @view perm[2:M + 1] + logu = logw[cutoff_ind] + logw_tail = @views logw[tail_inds] _, tail_dist = psis_tail!(logw_tail, logu, M, improved) warn && check_pareto_shape(tail_dist) return PSISResult(logw, LogExpFunctions.logsumexp(logw), reff_val, M, tail_dist) From b3e11cac2b583d354551f8a5819ac2181a420431 Mon Sep 17 00:00:00 2001 From: Seth Axen Date: Thu, 30 Dec 2021 18:22:56 +0100 Subject: [PATCH 3/4] Increment version number --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 554aff55..6a424db1 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PSIS" uuid = "ce719bf2-d5d0-4fb9-925d-10a81b42ad04" authors = ["Seth Axen and contributors"] -version = "0.2.5" +version = "0.2.6" [deps] Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" From ba6bf0ea92b1bff615b070ee12e6aad300affd96 Mon Sep 17 00:00:00 2001 From: Seth Axen Date: Thu, 30 Dec 2021 18:31:13 +0100 Subject: [PATCH 4/4] Update src/core.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/core.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core.jl b/src/core.jl index c21dc01b..7546aa6e 100644 --- a/src/core.jl +++ b/src/core.jl @@ -219,7 +219,7 @@ function psis!( end perm = partialsortperm(logw, (S - M):S) cutoff_ind = perm[1] - tail_inds = @view perm[2:M + 1] + tail_inds = @view perm[2:(M + 1)] logu = logw[cutoff_ind] logw_tail = @views logw[tail_inds] _, tail_dist = psis_tail!(logw_tail, logu, M, improved)