@@ -170,8 +170,6 @@ While `psis` computes smoothed log weights out-of-place, `psis!` smooths them in
170
170
171
171
# Keywords
172
172
173
- - `sorted=issorted(vec(log_ratios))`: whether `log_ratios` are already sorted. Only
174
- accepted if `nparams==1`.
175
173
- `improved=false`: If `true`, use the adaptive empirical prior of [^Zhang2010].
176
174
If `false`, use the simpler prior of [^ZhangStephens2009], which is also used in
177
175
[^VehtariSimpson2021].
207
205
function psis! (
208
206
logw:: AbstractVector ,
209
207
reff= 1 ;
210
- sorted:: Bool = issorted (logw),
208
+ sorted:: Bool = false , # deprecated
211
209
improved:: Bool = false ,
212
210
warn:: Bool = true ,
213
211
)
@@ -219,11 +217,11 @@ function psis!(
219
217
@warn " $M tail draws is insufficient to fit the generalized Pareto distribution. $MISSING_SHAPE_SUMMARY "
220
218
return PSISResult (logw, LogExpFunctions. logsumexp (logw), reff_val, M, missing )
221
219
end
222
- perm = sorted ? collect ( eachindex ( logw)) : sortperm (logw )
223
- icut = S - M
224
- tail_range = (icut + 1 ): S
225
- @inbounds logw_tail = @views logw[perm[tail_range] ]
226
- @inbounds logu = logw[perm[icut] ]
220
+ perm = partialsortperm ( logw, (S - M) : S )
221
+ cutoff_ind = perm[ 1 ]
222
+ tail_inds = @view perm[ 2 : (M + 1 )]
223
+ logu = logw[cutoff_ind ]
224
+ logw_tail = @views logw[tail_inds ]
227
225
_, tail_dist = psis_tail! (logw_tail, logu, M, improved)
228
226
warn && check_pareto_shape (tail_dist)
229
227
return PSISResult (logw, LogExpFunctions. logsumexp (logw), reff_val, M, tail_dist)
0 commit comments