JohannesBuchner / UltraNest

Fit and compare complex models reliably and rapidly. Advanced nested sampling.
https://johannesbuchner.github.io/UltraNest/
Other
142 stars 30 forks source link

vectorised slice sampler of fixed batch size #118

Closed njzifjoiez closed 4 months ago

njzifjoiez commented 6 months ago

I did some updates before creating the merge request. I changed the names of the function for PopulationSimpleSliceSampler as a working name, and I made some modifications regarding your second question so that the default setup is, I think, theoretically valid.

To answer your questions:

-> I selected different thresholds, Lmin or a likelihood above based on the points. Setting everything to Lmin also works. It was just an ad-hoc modification because ending the run was a bit faster. I remove it, I was already hesitating to do it.

-> yes indeed there is no stepping out procedure, the idea is more to have an interval that is larger than the area above Lmin so we don't have to steppout. If there is no scale adaptation, the idea is to have a slice that will reach the bound of the unit cube, so it is the type 1) interval of section 4.1 of Neal's paper. In the case of adaptation, the idea is to try to reduce it to fit the current regions so it would keep decreasing as the sampler focuses on a smaller area of the parameter space. So the current code would need some adaptations to adjust this behaviour when ultranest is re-sampling areas of lower likelihood, maybe a reset in the scale or something like that. The jitter is here to balance an adaptation that would be too strong and impose a too small slice width. Though I agree with you, I don't think that it preserves the detailed balance with the jitter, but I am also not sure that it is preserved with the scale adaptation. I kept them because the runs tend to end faster when activated, but I am not sure of how robust it is. So, I changed the default setup to the constant slice width.

To give some insight into the performance, I ran some tests this morning on my laptop with a 20d rosenbrock problem. I ran the default setup for my sampler, the normal slice sampler and the current population one, and here are the last printing of the runs:

My sampler: time -p python test_PopSliceSampler.py --x_dim 20 --log_dir test --rosenbrock --seed 4 --SimSlice --popsize 50 --nstep 100 --direction 1 --num_live_points 600

[ultranest] Explored until L=-2  .88 [-32.8228..-4.0819] | it/evals=79800/39819700 eff=0.1980% N=1200 
[ultranest] Likelihood function evaluations: 39819700
[ultranest] Writing samples and results to disk ...
[ultranest] Writing samples and results to disk ... done
[ultranest]   logZ = -113.9 +- 0.2594
[ultranest] Effective samples strategy satisfied (ESS = 14320.9, need >400)
[ultranest] Posterior uncertainty strategy is satisfied (KL: 0.46+-0.05 nat, need <0.50 nat)
[ultranest] Evidency uncertainty strategy wants 299 minimum live points (dlogz from 0.23 to 0.76, need <0.5)
[ultranest]   logZ error budget: single: 0.29 bs:0.26 tail:0.01 total:0.26 required:<0.50
[ultranest] done iterating.

logZ = -113.972 +- 0.758
  single instance: logZ = -113.972 +- 0.416
  bootstrapped   : logZ = -113.875 +- 0.758
  tail           : logZ = +- 0.008
insert order U test : converged: True correlation: inf iterations

    param1              : 0.856 │ ▁▁▁▁▁▁▁▁▁▁▁▂▂▃▄▅▅▆▇▇▇▇▇▆▄▃▃▂▁▁▁▁▁▁▁▁▁ │1.121     0.997 +- 0.029
    param2              : 0.863 │ ▁ ▁▁▁▁▁▁▁▁▁▂▂▃▄▅▆▆▇▇▇▇▆▅▅▄▃▂▂▁▁▁▁▁▁▁▁ │1.113     0.997 +- 0.029
    param3              : 0.832 │ ▁  ▁▁▁▁▁▁▁▁▁▁▂▂▃▄▅▆▇▇▇▇▆▅▄▃▂▁▁▁▁▁▁▁▁▁ │1.127     0.997 +- 0.029
    param4              : 0.858 │ ▁▁▁▁▁▁▁▁▁▁▁▂▂▃▄▅▅▆▇▇▇▇▇▆▅▄▃▂▂▁▁▁▁▁▁▁▁ │1.115     0.997 +- 0.029
    param5              : 0.852 │ ▁ ▁▁▁▁▁▁▁▁▁▁▂▂▃▄▅▆▇▇▇▇▆▆▅▄▃▂▁▁▁▁▁▁▁▁▁ │1.119     0.997 +- 0.029
    param6              : 0.853 │ ▁ ▁▁▁▁▁▁▁▁▁▁▂▃▃▄▅▆▇▇▇▇▆▅▅▄▃▂▁▁▁▁▁▁▁▁▁ │1.119     0.997 +- 0.029
    param7              : 0.857 │ ▁▁▁▁▁▁▁▁▁▁▁▂▂▃▄▅▆▇▇▇▇▇▆▅▄▃▂▁▁▁▁▁▁▁▁▁▁ │1.127     0.996 +- 0.029
    param8              : 0.821 │ ▁▁ ▁ ▁▁▁▁▁▁▁▁▁▂▃▄▅▆▇▇▇▇▆▅▄▃▂▁▁▁▁▁▁▁▁▁ │1.131     0.996 +- 0.029
    param9              : 0.653 │ ▁       ▁  ▁  ▁▁▁▁▁▁▁▁▂▃▅▆▇▇▆▄▂▁▁▁▁▁▁ │1.136     0.996 +- 0.029
    param10             : 0.519 │ ▁  ▁    ▁  ▁  ▁▁▁▁▁▁▁▁▁▁▁▁▂▄▆▇▇▅▃▁▁▁▁ │1.127     0.995 +- 0.029
    param11             : 0.247 │ ▁    ▁  ▁  ▁ ▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▂▄▇▇▄▂▁▁▁ │1.157     0.994 +- 0.030
    param12             : 0.152 │ ▁▁   ▁▁ ▁ ▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▄▇▇▄▁▁▁ │1.149     0.991 +- 0.033
    param13             : -0.063│ ▁ ▁ ▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▄▇▆▂▁▁ │1.156     0.986 +- 0.040
    param14             : -0.109│ ▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▅▇▅▂▁▁ │1.164     0.976 +- 0.054
    param15             : -0.130│ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▃▅▇▆▃▁▁ │1.158     0.957 +- 0.080
    param16             : -0.18 │ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▃▄▆▇▇▅▂▁▁ │1.19      0.92 +- 0.12
    param17             : -0.22 │ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂▃▄▄▅▆▇▇▇▅▃▂▁▁ │1.25      0.87 +- 0.18
    param18             : -0.19 │ ▁▁▁▁▁▁▁▁▁▁▂▂▂▂▃▃▄▄▄▅▅▆▇▇▇▇▇▇▆▅▄▃▂▁▁▁▁ │1.45      0.79 +- 0.26
    param19             : -0.30 │ ▁▁▁▂▃▄▄▄▅▅▆▆▆▇▇▇▇▇▇▇▆▆▅▅▄▃▃▂▂▁▁▁▁▁▁▁▁ │1.98      0.70 +- 0.38
    param20             : -0.35 │ ▁▂▇▇▆▅▅▅▄▄▃▃▃▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ │3.75      0.63 +- 0.57

real 655,91
user 1487,72
sys 3338,18

Current population slice sampler time -p python test_PopSliceSampler.py --x_dim 20 --log_dir test --rosenbrock --seed 4 --PopSlice --popsize 50 --nstep 100 --direction 1 --num_live_points 600

[ultranest] Explored until L=-6  .53 [-9.8660..-9.8641]*| it/evals=63953/105400542 eff=0.0607% N=599 
[ultranest] Likelihood function evaluations: 105400542
[ultranest] Writing samples and results to disk ...
[ultranest] Writing samples and results to disk ... done
[ultranest]   logZ = -114.3 +- 0.2714
[ultranest] Effective samples strategy satisfied (ESS = 547.4, need >400)
[ultranest] Posterior uncertainty strategy is satisfied (KL: 0.45+-0.09 nat, need <0.50 nat)
/home/benjamin/mambaforge/lib/python3.10/site-packages/ultranest-3.6.4-py3.10-linux-x86_64.egg/ultranest/integrator.py:1723: RuntimeWarning: invalid value encountered in cast
  nlive_sets, niter = np.unique(nlive.astype(int), return_counts=True)
[ultranest] Evidency uncertainty strategy wants 597 minimum live points (dlogz from 0.21 to 0.71, need <0.5)
[ultranest]   logZ error budget: single: 0.41 bs:0.27 tail:0.41 total:0.49 required:<0.50
[ultranest] done iterating.

logZ = -114.297 +- 0.820
  single instance: logZ = -114.297 +- 0.412
  bootstrapped   : logZ = -114.258 +- 0.713
  tail           : logZ = +- 0.406
insert order U test : converged: True correlation: 57913 iterations

    param1              : 0.854 │ ▁▁▁▁▁▁▁▁▁▁▁▂▃▅▃▅▇▆▆▇▇▆▅▅▄▄▂▂▁▁▁▁▁▁▁ ▁ │1.125     0.995 +- 0.029
    param2              : 0.859 │ ▁ ▁▁▁▁▁▁▁▁▁▁▂▂▅▅▆▆▅▇▆▇▄▄▄▃▃▂▁▁▁▁▁▁▁ ▁ │1.118     0.996 +- 0.029
    param3              : 0.850 │ ▁  ▁▁▁▁▁▁▁▁▁▁▃▂▃▄▆▇▇▆▇▅▇▇▇▄▄▃▂▂▁▁▁▁▁▁ │1.105     0.997 +- 0.030
    param4              : 0.858 │ ▁▁▁▁▁▁▁▁▁▁▁▂▂▂▂▄▄▅▄▇▇▆▅▅▃▂▂▂▁▁▁▁▁▁▁▁▁ │1.115     0.996 +- 0.028
    param5              : 0.853 │ ▁ ▁▁▁▁▁▁▁▁▁▂▂▂▃▄▅▇▇▆▆▆▄▃▃▂▂▁▁▁▁▁▁▁▁▁▁ │1.128     0.995 +- 0.028
    param6              : 0.727 │ ▁           ▁▁▁▁▁▁▁▂▃▄▆▇▇▅▅▃▃▁▁▁▁▁▁▁▁ │1.144     0.995 +- 0.028
    param7              : 0.630 │ ▁               ▁▁▁▁▁▁▁▂▃▅▇▇▇▆▄▂▁▁▁▁▁ │1.129     0.996 +- 0.030
    param8              : 0.281 │ ▁                     ▁▁▁▁▁▁▂▅▇▇▄▂▁▁▁ │1.154     0.995 +- 0.029
    param9              : 0.045 │ ▁                 ▁   ▁▁▁▁▁▁▁▁▁▄▇▅▂▁▁ │1.145     0.994 +- 0.029
    param10             : -0.050│ ▁          ▁     ▁▁▁  ▁▁▁▁▁▁▁▁▁▄▇▅▂▁▁ │1.162     0.994 +- 0.031
    param11             : 0.017 │ ▁  ▁  ▁   ▁▁▁  ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▃▇▇▃▁▁▁ │1.169     0.992 +- 0.032
    param12             : 0.012 │ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▅▇▅▂▁▁ │1.151     0.990 +- 0.039
    param13             : -0.110│ ▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▃▇▆▂▁▁ │1.162     0.984 +- 0.050
    param14             : -0.119│ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▄▆▇▃▁▁ │1.158     0.974 +- 0.070
    param15             : -0.142│ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▃▅▇▇▅▁▁ │1.152     0.953 +- 0.099
    param16             : -0.18 │ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▃▄▆▆▇▇▄▁▁ │1.18      0.92 +- 0.14
    param17             : -0.26 │ ▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▃▃▄▅▅▆▆▇▇▆▃▁▁ │1.22      0.87 +- 0.20
    param18             : -0.28 │ ▁ ▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂▃▃▃▄▅▄▅▅▅▄▄▅▆▇▂▃▂▁▁▁ │1.41      0.79 +- 0.28
    param19             : -0.29 │ ▁▁▁▂▄▄▃▄▄▅▅▆▆▅▇▆▇▆▇▆▄▅▆▇▅▅▇▄▂▃▂▂▂▁▁▁▁ │1.82      0.71 +- 0.40
    param20             : -0.36 │ ▁▁▃▇▇▅▅▄▄▄▃▃▂▂▃▃▂▂▃▃▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁ │3.07      0.66 +- 0.59

real 1165,90
user 1583,49
sys 1645,41

Normal slice sampler: time -p python test_PopSliceSampler.py --x_dim 20 --log_dir test --rosenbrock --seed 4 --Slice --popsize 50 --nstep 100 --direction 1 --num_live_points 600

[ultranest] Explored until L=-1  .48 [-32.5858..-3.3628] | it/evals=83414/41131828 eff=0.1918% N=1200 
[ultranest] Likelihood function evaluations: 41132292
[ultranest] Writing samples and results to disk ...
[ultranest] Writing samples and results to disk ... done
[ultranest]   logZ = -114.6 +- 0.2815
[ultranest] Effective samples strategy satisfied (ESS = 14378.0, need >400)
[ultranest] Posterior uncertainty strategy is satisfied (KL: 0.45+-0.07 nat, need <0.50 nat)
[ultranest] Evidency uncertainty strategy wants 299 minimum live points (dlogz from 0.22 to 0.63, need <0.5)
[ultranest]   logZ error budget: single: 0.29 bs:0.28 tail:0.00 total:0.28 required:<0.50
[ultranest] done iterating.

logZ = -114.625 +- 0.628
  single instance: logZ = -114.625 +- 0.416
  bootstrapped   : logZ = -114.590 +- 0.628
  tail           : logZ = +- 0.002
insert order U test : converged: True correlation: inf iterations

    param1              : 0.854 │ ▁▁▁▁▁▁▁▁▁▁▁▂▃▄▅▆▆▇▇▇▇▆▅▃▃▂▁▁▁▁▁▁▁▁  ▁ │1.144     0.997 +- 0.029
    param2              : 0.852 │ ▁ ▁▁▁▁▁▁▁▁▁▂▃▃▄▅▆▇▇▇▇▆▅▄▃▂▁▁▁▁▁▁▁   ▁ │1.140     0.997 +- 0.029
    param3              : 0.853 │ ▁▁▁▁▁▁▁▁▁▁▁▁▂▃▃▄▅▆▇▇▇▇▇▆▅▄▃▂▂▁▁▁▁▁▁▁▁ │1.116     0.997 +- 0.029
    param4              : 0.853 │ ▁ ▁▁▁▁▁▁▁▁▁▂▂▃▄▅▆▇▇▇▇▇▆▅▄▃▂▁▁▁▁▁▁▁▁▁▁ │1.130     0.997 +- 0.029
    param5              : 0.859 │ ▁▁▁▁▁▁▁▁▁▁▁▂▂▃▄▅▆▆▇▇▇▇▆▆▅▄▃▂▂▁▁▁▁▁▁▁▁ │1.116     0.997 +- 0.029
    param6              : 0.856 │ ▁▁▁▁▁▁▁▁▁▁▁▂▂▃▄▅▆▇▇▇▇▆▆▅▄▃▂▂▁▁▁▁▁▁▁▁▁ │1.124     0.996 +- 0.029
    param7              : 0.823 │ ▁  ▁▁▁▁▁▁▁▁▁▁▁▂▃▄▅▆▇▇▇▇▆▅▄▃▂▁▁▁▁▁▁▁▁▁ │1.129     0.996 +- 0.030
    param8              : 0.759 │ ▁     ▁▁  ▁▁▁▁▁▁▁▁▂▃▄▆▇▇▇▇▆▄▃▂▁▁▁▁▁ ▁ │1.129     0.996 +- 0.029
    param9              : 0.484 │ ▁      ▁▁  ▁    ▁  ▁▁▁▁▁▁▁▂▃▆▇▇▆▃▁▁▁▁ │1.131     0.996 +- 0.029
    param10             : 0.163 │ ▁      ▁  ▁   ▁ ▁   ▁▁▁▁▁▁▁▁▁▂▄▇▇▄▁▁▁ │1.149     0.995 +- 0.030
    param11             : 0.001 │ ▁    ▁  ▁ ▁ ▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▅▇▆▂▁▁ │1.154     0.994 +- 0.031
    param12             : -0.080│ ▁▁▁   ▁▁ ▁ ▁▁ ▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▃▇▇▂▁▁▁ │1.194     0.991 +- 0.035
    param13             : -0.146│ ▁  ▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▃▇▇▃▁▁ │1.157     0.985 +- 0.042
    param14             : -0.145│ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▄▇▇▂▁▁ │1.160     0.975 +- 0.057
    param15             : -0.090│ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▄▆▇▆▂▁▁ │1.162     0.956 +- 0.083
    param16             : -0.16 │ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▃▄▆▇▇▅▂▁▁ │1.19      0.92 +- 0.12
    param17             : -0.22 │ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂▃▄▅▆▆▇▇▇▅▃▁▁▁ │1.26      0.87 +- 0.19
    param18             : -0.24 │ ▁▁▁▁▁▁▁▁▁▁▂▂▂▂▂▃▃▃▄▅▆▆▆▇▇▇▇▇▇▆▅▃▂▁▁▁▁ │1.44      0.80 +- 0.27
    param19             : -0.26 │ ▁▁▁▃▄▄▄▅▅▆▆▆▇▇▇▇▇▇▇▇▇▇▆▅▅▄▄▃▂▂▁▁▁▁▁▁▁ │1.93      0.71 +- 0.38
    param20             : -0.36 │ ▁▁▆▇▆▆▅▅▄▄▃▃▃▃▂▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ │3.48      0.64 +- 0.57

real 1480,20
user 2162,93
sys 2654,07

I made the same run with the adaptation of the slice size (adapt factor of 0.9) and another with the same adaptation+jitter. So, there may not be a correct sampling strategy as their logZ is higher than the three other runs, but the runs were faster.

Adaptation only:

[ultranest] Explored until L=-2  .32 [-32.8593..-5.0509] | it/evals=77227/41790350 eff=0.1754% N=1200 
[ultranest] Likelihood function evaluations: 41790350
[ultranest] Writing samples and results to disk ...
[ultranest] Writing samples and results to disk ... done
[ultranest]   logZ = -112.8 +- 0.3042
[ultranest] Effective samples strategy satisfied (ESS = 13820.5, need >400)
[ultranest] Posterior uncertainty strategy is satisfied (KL: 0.46+-0.04 nat, need <0.50 nat)
[ultranest] Evidency uncertainty strategy wants 299 minimum live points (dlogz from 0.25 to 0.59, need <0.5)
[ultranest]   logZ error budget: single: 0.29 bs:0.30 tail:0.03 total:0.31 required:<0.50
[ultranest] done iterating.

logZ = -112.816 +- 0.552
  single instance: logZ = -112.816 +- 0.413
  bootstrapped   : logZ = -112.822 +- 0.551
  tail           : logZ = +- 0.027
insert order U test : converged: True correlation: inf iterations

    param1              : 0.860 │ ▁▁▁▁▁▁▁▁▁▁▂▂▃▄▅▆▆▇▇▇▇▆▅▄▃▂▂▁▁▁▁▁▁▁▁ ▁ │1.133     0.997 +- 0.029
    param2              : 0.847 │ ▁ ▁▁▁▁▁▁▁▁▁▁▂▂▃▄▅▅▆▇▇▇▇▆▅▄▃▂▂▁▁▁▁▁▁▁▁ │1.117     0.997 +- 0.029
    param3              : 0.850 │ ▁▁▁▁▁▁▁▁▁▁▁▂▂▃▄▅▆▇▇▇▇▇▆▅▄▃▂▁▁▁▁▁▁▁  ▁ │1.130     0.997 +- 0.029
    param4              : 0.842 │ ▁  ▁▁▁▁▁▁▁▁▁▂▃▃▅▅▆▇▇▇▇▆▅▃▂▂▁▁▁▁▁▁▁  ▁ │1.137     0.997 +- 0.029
    param5              : 0.859 │ ▁▁▁▁▁▁▁▁▁▁▁▂▂▃▄▅▆▇▇▇▇▇▆▅▄▃▂▂▁▁▁▁▁▁▁▁▁ │1.122     0.996 +- 0.029
    param6              : 0.845 │ ▁  ▁▁▁▁▁▁▁▁▁▁▂▂▃▄▅▆▇▇▇▇▆▅▄▃▂▂▁▁▁▁▁▁▁▁ │1.117     0.997 +- 0.029
    param7              : 0.819 │ ▁    ▁▁▁▁▁▁▁▁▁▂▃▄▅▆▆▇▇▇▆▅▄▃▂▁▁▁▁▁▁▁▁▁ │1.133     0.997 +- 0.029
    param8              : 0.714 │ ▁            ▁▁▁▁▁▁▁▂▃▅▆▇▇▇▅▄▃▁▁▁▁▁▁▁ │1.134     0.996 +- 0.029
    param9              : 0.504 │ ▁            ▁  ▁   ▁▁▁▁▁▂▃▆▇▇▆▃▁▁▁▁▁ │1.146     0.996 +- 0.029
    param10             : 0.256 │ ▁       ▁         ▁  ▁▁▁▁▁▁▁▂▅▇▇▄▁▁▁▁ │1.163     0.996 +- 0.030
    param11             : 0.087 │ ▁ ▁            ▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▂▆▇▅▁▁▁ │1.151     0.995 +- 0.031
    param12             : -0.074│ ▁ ▁         ▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▃▇▇▃▁▁ │1.151     0.992 +- 0.033
    param13             : -0.028│ ▁ ▁▁▁▁▁ ▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▄▇▇▃▁▁ │1.144     0.986 +- 0.040
    param14             : -0.112│ ▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▅▇▆▂▁▁ │1.165     0.977 +- 0.054
    param15             : -0.154│ ▁  ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▃▅▇▇▄▁▁ │1.153     0.959 +- 0.081
    param16             : -0.17 │ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▃▄▅▇▇▆▃▁▁ │1.18      0.93 +- 0.12
    param17             : -0.20 │ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂▃▄▅▆▇▇▇▇▅▃▁▁▁ │1.27      0.88 +- 0.18
    param18             : -0.20 │ ▁▁▁▁▁▁▁▁▁▁▁▂▂▂▂▃▃▃▄▄▅▅▆▇▆▇▇▇▆▅▄▄▃▂▁▁▁ │1.44      0.81 +- 0.27
    param19             : -0.28 │ ▁▁▁▂▃▄▄▄▅▅▆▆▇▆▇▇▇▇▇▇▆▆▆▅▄▄▄▃▂▂▁▁▁▁▁▁▁ │1.98      0.73 +- 0.39
    param20             : -0.39 │ ▁▁▅▇▆▆▅▅▄▄▄▃▃▃▂▂▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ │3.65      0.68 +- 0.60

real 522,16
user 1273,88
sys 2952,64

Here with the jitter+adaptation

[ultranest] Explored until L=-5  5.21 [-10.0181..-10.0136]*| it/evals=61860/33614850 eff=0.1840% N=600 
[ultranest] Likelihood function evaluations: 33614850
[ultranest] Writing samples and results to disk ...
[ultranest] Writing samples and results to disk ... done
[ultranest]   logZ = -111 +- 0.3849
[ultranest] Effective samples strategy satisfied (ESS = 410.5, need >400)
[ultranest] Posterior uncertainty strategy is satisfied (KL: 0.45+-0.09 nat, need <0.50 nat)
[ultranest] Evidency uncertainty strategy wants 598 minimum live points (dlogz from 0.31 to 0.88, need <0.5)
[ultranest]   logZ error budget: single: 0.41 bs:0.38 tail:0.41 total:0.56 required:<0.50
[ultranest] done iterating.

logZ = -110.974 +- 0.965
  single instance: logZ = -110.974 +- 0.405
  bootstrapped   : logZ = -111.010 +- 0.875
  tail           : logZ = +- 0.406
insert order U test : converged: True correlation: inf iterations

    param1              : 0.870 │ ▁▁▁▁▁▁▁▁▁▂▂▂▂▆▅▅▇▆▇▇▇▇▇▆▄▃▃▂▂▁▁▁▁▁▁▁▁ │1.113     0.996 +- 0.029
    param2              : 0.860 │ ▁▁▁▁▁▁▁▁▁▁▁▂▄▄▅▄▇▆▇▇▆▅▆▄▄▃▂▂▁▁▁▁▁▁▁ ▁ │1.124     0.995 +- 0.030
    param3              : 0.868 │ ▁▁▁▁▁▁▁▁▁▂▂▃▃▄▆▅▅▆▇▅▄▄▄▂▂▁▁▁▁▁▁▁▁▁▁ ▁ │1.140     0.996 +- 0.029
    param4              : 0.851 │ ▁▁▁▁▁▁▁▁▁▁▁▁▂▂▃▅▅▆▇▆▆▇▆▄▄▄▃▂▁▁▁▁▁▁▁ ▁ │1.119     0.996 +- 0.029
    param5              : 0.867 │ ▁▁▁▁▁▁▁▁▁▁▁▂▂▂▄▆▆▅▆▇▆▅▅▅▅▄▂▂▁▁▁▁▁▁▁▁▁ │1.108     0.995 +- 0.029
    param6              : 0.874 │ ▁▁▁▁▁▁▁▁▁▂▂▃▄▄▇▇▇▆▇▆▅▄▄▃▂▂▁▁▁▁▁▁▁▁▁ ▁ │1.134     0.995 +- 0.029
    param7              : 0.861 │ ▁▁▁▁▁▁▁▁▁▁▂▂▂▂▄▅▄▇▆▇▆▅▆▆▄▃▃▂▁▁▁▁▁▁▁▁▁ │1.112     0.995 +- 0.030
    param8              : 0.813 │ ▁    ▁ ▁▁▁▁▁▁▁▁▂▃▃▄▇▇▇▅▅▅▃▃▂▁▁▁▁▁▁▁ ▁ │1.131     0.995 +- 0.028
    param9              : 0.723 │ ▁    ▁    ▁▁▁▁▁▁▁▁▁▁▂▂▄▅▇▄▅▄▃▃▂▁▁▁▁▁▁ │1.127     0.994 +- 0.029
    param10             : 0.468 │ ▁       ▁   ▁  ▁▁▁▁▁▁▁▁▁▁▁▁▂▅▇▇▆▃▂▁▁▁ │1.127     0.993 +- 0.029
    param11             : 0.238 │ ▁    ▁     ▁ ▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▄▇▅▃▁▁▁ │1.140     0.992 +- 0.031
    param12             : 0.017 │ ▁    ▁   ▁▁ ▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▃▇▇▃▁▁▁ │1.164     0.989 +- 0.033
    param13             : -0.046│ ▁ ▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▃▆▇▄▁▁▁ │1.167     0.984 +- 0.042
    param14             : -0.142│ ▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▄▆▇▃▁▁ │1.151     0.972 +- 0.057
    param15             : -0.115│ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▄▆▇▆▃▁▁ │1.157     0.952 +- 0.085
    param16             : -0.13 │ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▃▃▅▅▇▇▅▂▁▁ │1.18      0.91 +- 0.13
    param17             : -0.20 │ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂▄▃▃▄▅▇▅▅▃▁▁▁▁ │1.26      0.85 +- 0.19
    param18             : -0.22 │ ▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂▃▂▃▅▃▃▃▄▅▄▅▇▅▅▃▄▃▂▁▁▁▁ │1.39      0.76 +- 0.27
    param19             : -0.23 │ ▁▁▁▃▄▄▆▄▅▅▇▄▅▅▇▅▆▄▇▆▇▆▇▃▃▄▃▃▂▂▁▁▁▁▁▁▁ │1.82      0.66 +- 0.37
    param20             : -0.29 │ ▁▂▇▇▄▄▃▄▃▄▃▃▃▂▂▁▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ │3.07      0.57 +- 0.54

real 378,16
user 848,53
sys 1849,87
njzifjoiez commented 6 months ago

I have pushed two commits (2111ea4 and eb7581) this morning with some modifications regarding your comments, mainly changing the Theta notations, improving the docstring and moving out some functions of the main sampler.

I messed up a bit, and the change is split between both commits. There is one comment I didn't get about the docstring, but I will continue on it in the specific thread. I haven't advanced on the unit tests for the different functions, I will look at that next. Let me know if there are more things to do about some notations/docstring that would need to be change.

Note: I added by mistake a python file in the first commit to parse some test results; I removed it; it's not related to the change here.

JohannesBuchner commented 5 months ago

I am glad to see you are progressing here. I left a few more comments.

The latest version of ultranest (>4.1) has a cool new feature diagnosing the random walk effectiveness, giving the user feedback. I think this prevents merging currently, so you may have to upgrade (rebase/pull) first. It would be nice if your new step sampler also has these capabilities.

njzifjoiez commented 4 months ago

Hi there,

I advanced on the unit tests and caught the current version of the code. I added unit tests for the functions used in the sampler and a sanity check for the sampler by itself. The idea of the last one is to run one step of the sampler from a random set of points and check that the new points have all L>Lmin , are in the unit cube and are on the slice defined at the beginning of this iteration. I can add more sanity check there, I just thought of these three points. Let me know if you're good with that or if I should add more stuff there.

I also found that JAXNS was using a similar method for their slice sampler in the last paper here: https://arxiv.org/abs/2312.11330 They mention in section 3 that they remove the step-out procedure and use the bound of the sampling space as in the default case for the sampler here. Instead of my procedure with a scale, they are shrinking at the midpoint between the initial and proposed points. So I added a new parameter, a shrink_factor, that accelerates the shrinking in the same way. When it is 2, we get the midpoint, but it can be set to another value. I added a condition that it should always be larger than one to accelerate compared to the default case. I think it may be more robust than my initial guess. Let me know what you think; I added new tests at the end of the msg here with the different modes of the sampler with the current version of the code.

I also tried to run the calibrator on my sampler after adding the new things that I saw on the other population step sampler. However, it seems that they are not currently working on it. My test broke when the method check_nsteps and adaptive_nsteps were called in ReactiveNestedCalibrator.run. I try to look at the normal step sampler, but it would be easier if you add them on the population step sampler, it would be surely very similar to what i need to do with this one. I am unsure about what I did for the logstat. I looked at the implementations PopulationRandomWalkSampler and PopulationSliceSampler. I think the first has a typo because 6 elements were added instead of 5. My guess for my sampler was that far_enough, mean_rel_jump should be the same. scale is the scale, but in the default case it is not use as I use the bound of the unit cube, so it is always 1. I was wondering about the two last ones. I should have an accept_rate of 1 because we always find new points theoretically. As my while loop has a number of step limits, it may not be the case for a specific step. So i am not sure what I should add here, because If they have not found new points for each of the starting one, the code should exit before. I am not sure of what the efficiency means here too.

Here is the simple slice sampler test to compare with the version 4.2, ran with: time -p python test_PopSliceSampler.py --x_dim 20 --log_dir test --problem rosenbrock --seed 4 --Sampler Slice --popsize 50 --nstep 100 --direction 1 --num_live_points 600

[ultranest] Explored until L=-2  .83 [-34.5093..-4.3387] | it/evals=80825/42548190 eff=0.1775% N=1200 
[ultranest] Likelihood function evaluations: 42549282
[ultranest] Writing samples and results to disk ...
[ultranest] Writing samples and results to disk ... done
[ultranest]   logZ = -114.7 +- 0.3289
[ultranest] Effective samples strategy satisfied (ESS = 14639.2, need >400)
[ultranest] Posterior uncertainty strategy is satisfied (KL: 0.46+-0.04 nat, need <0.50 nat)
[ultranest] Evidency uncertainty strategy wants 299 minimum live points (dlogz from 0.28 to 0.80, need <0.5)
[ultranest]   logZ error budget: single: 0.29 bs:0.33 tail:0.01 total:0.33 required:<0.50
[ultranest] done iterating.

logZ = -114.679 +- 0.524
  single instance: logZ = -114.679 +- 0.417
  bootstrapped   : logZ = -114.677 +- 0.524
  tail           : logZ = +- 0.012
insert order U test : converged: True correlation: inf iterations
step sampler diagnostic: jump distance 1.09 (should be >1), far enough fraction: 70.75%  (should be >50%)

    param1              : -1.128│ ▁▁                              ▁▂▇▂▁ │1.212     0.997 +- 0.034
    param2              : 0.863 │ ▁ ▁▁▁▁▁▁▁▁▁▂▂▃▄▅▆▇▇▇▇▇▇▆▅▄▃▂▂▁▁▁▁▁▁▁▁ │1.115     0.997 +- 0.029
    param3              : 0.860 │ ▁▁▁▁▁▁▁▁▁▁▁▂▂▃▄▅▆▇▇▇▇▇▆▅▄▃▂▂▁▁▁▁▁▁▁▁▁ │1.124     0.997 +- 0.029
    param4              : 0.849 │ ▁  ▁▁▁▁▁▁▁▁▁▂▂▃▄▅▆▇▇▇▇▇▆▅▄▃▂▁▁▁▁▁▁▁▁▁ │1.119     0.997 +- 0.029
    param5              : 0.836 │ ▁   ▁▁▁▁▁▁▁▁▁▂▂▃▄▅▆▇▇▇▇▇▆▄▃▂▂▁▁▁▁▁▁▁▁ │1.121     0.997 +- 0.029
    param6              : 0.650 │ ▁               ▁▁▁▁▁▁▂▄▅▇▇▇▅▄▂▁▁▁▁▁▁ │1.143     0.997 +- 0.029
    param7              : 0.390 │ ▁                     ▁▁▁▁▁▂▄▆▇▆▃▁▁▁▁ │1.143     0.997 +- 0.029
    param8              : 0.037 │ ▁                     ▁   ▁▁▁▁▂▆▇▄▁▁▁ │1.165     0.996 +- 0.029
    param9              : -0.110│ ▁                  ▁   ▁▁▁▁▁▁▁▁▄▇▅▁▁▁ │1.178     0.996 +- 0.030
    param10             : -0.110│ ▁           ▁  ▁ ▁▁▁▁▁ ▁▁▁▁▁▁▁▁▄▇▆▂▁▁ │1.168     0.995 +- 0.030
    param11             : -0.109│ ▁     ▁    ▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▄▇▆▂▁▁ │1.168     0.993 +- 0.032
    param12             : -0.009│ ▁▁▁▁▁▁ ▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▅▇▅▁▁▁ │1.160     0.990 +- 0.037
    param13             : -0.114│ ▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▄▇▆▂▁▁ │1.161     0.984 +- 0.046
    param14             : -0.140│ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▄▇▆▂▁▁ │1.162     0.972 +- 0.063
    param15             : -0.227│ ▁  ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▄▇▇▄▁▁ │1.154     0.952 +- 0.091
    param16             : -0.18 │ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▃▄▅▇▇▆▂▁▁ │1.18      0.92 +- 0.13
    param17             : -0.19 │ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂▃▄▄▆▆▇▇▇▆▄▂▁▁ │1.24      0.86 +- 0.19
    param18             : -0.25 │ ▁▁▁▁▁▁▁▁▁▁▁▂▂▂▂▃▃▄▄▅▅▆▇▇▇▇▇▇▆▅▄▃▂▁▁▁▁ │1.46      0.78 +- 0.27
    param19             : -0.27 │ ▁▁▁▂▄▄▄▄▅▅▆▆▇▇▇▇▇▇▇▇▆▆▆▄▄▃▃▂▂▁▁▁▁▁▁▁▁ │1.95      0.68 +- 0.37
    param20             : -0.40 │ ▁▁▄▇▆▅▅▅▄▄▃▃▃▃▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁ ▁ │3.58      0.59 +- 0.53

real 1332,13
user 1487,27
sys 554,46

Here is the default case for my sampler, ran with: time -p python test_PopSliceSampler.py --x_dim 20 --log_dir test --problem rosenbrock --seed 4 --Sampler SimSlice --popsize 50 --nstep 100 --direction 1 --num_live_points 600

[ultranest] Explored until L=-6  5.59 [-10.0733..-10.0715]*| it/evals=64577/59552450 eff=0.1084% N=599 
[ultranest] Likelihood function evaluations: 59552450
[ultranest] Writing samples and results to disk ...
[ultranest] Writing samples and results to disk ... done
[ultranest]   logZ = -115.6 +- 0.2828
[ultranest] Effective samples strategy satisfied (ESS = 549.2, need >400)
[ultranest] Posterior uncertainty strategy is satisfied (KL: 0.45+-0.11 nat, need <0.50 nat)
[ultranest] Evidency uncertainty strategy wants 597 minimum live points (dlogz from 0.24 to 0.62, need <0.5)
[ultranest]   logZ error budget: single: 0.41 bs:0.28 tail:0.41 total:0.49 required:<0.50
[ultranest] done iterating.

logZ = -115.572 +- 0.745
  single instance: logZ = -115.572 +- 0.414
  bootstrapped   : logZ = -115.606 +- 0.624
  tail           : logZ = +- 0.406
insert order U test : converged: True correlation: inf iterations
step sampler diagnostic: jump distance 1.09 (should be >1), far enough fraction: 70.74%  (should be >50%)

    param1              : 0.840 │ ▁   ▁▁▁▁▁▁▁▁▁▂▄▃▄▅▆▇▇▇▆▆▄▃▃▂▁▁▁▁▁▁▁▁▁ │1.130     0.997 +- 0.029
    param2              : 0.869 │ ▁▁▁▁▁▁▁▁▁▁▂▂▂▃▄▄▆▄▇▆▇▄▄▆▄▃▂▂▁▁▁▁▁▁▁▁▁ │1.116     0.997 +- 0.029
    param3              : 0.865 │ ▁▁▁▁▁▁▁▁▁▁▂▂▃▃▄▆▆▆▇▇▇▆▆▄▄▂▂▁▁▁▁▁▁▁ ▁▁ │1.125     0.997 +- 0.029
    param4              : 0.857 │ ▁▁▁▁▁▁▁▁▁▁▁▂▂▂▃▄▄▅▇▅▇▄▄▃▃▃▂▂▁▁▁▁▁▁▁▁▁ │1.128     0.997 +- 0.030
    param5              : 0.816 │ ▁    ▁▁▁▁▁▁▁▁▁▁▂▂▃▄▆▆▅▇▇▇▅▆▃▃▂▁▁▁▁▁▁▁ │1.117     0.998 +- 0.030
    param6              : 0.687 │ ▁            ▁▁▁▁▁▁▁▁▂▃▄▆▇▆▆▅▃▂▁▁▁▁▁▁ │1.130     0.995 +- 0.029
    param7              : 0.531 │ ▁            ▁     ▁▁▁▁▁▁▂▃▅▇▇▆▄▂▁▁▁▁ │1.130     0.995 +- 0.029
    param8              : 0.215 │ ▁             ▁          ▁▁▁▁▃▆▇▅▂▁▁▁ │1.157     0.994 +- 0.029
    param9              : -0.013│ ▁          ▁              ▁▁▁▁▂▆▇▅▂▁▁ │1.163     0.994 +- 0.031
    param10             : -0.067│ ▁     ▁              ▁▁▁▁▁▁▁▁▁▂▆▇▅▁▁▁ │1.174     0.995 +- 0.032
    param11             : 0.028 │ ▁           ▁ ▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▂▅▇▇▂▁▁ │1.147     0.993 +- 0.034
    param12             : -0.100│ ▁  ▁    ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▃▇▇▂▁▁ │1.159     0.990 +- 0.038
    param13             : -0.004│ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▆▇▅▁▁▁ │1.160     0.984 +- 0.050
    param14             : -0.089│ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▅▇▅▂▁▁ │1.161     0.972 +- 0.069
    param15             : -0.175│ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▃▅▇▆▃▁▁ │1.159     0.954 +- 0.095
    param16             : -0.17 │ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂▃▆▆▇▅▃▁▁ │1.17      0.92 +- 0.13
    param17             : -0.20 │ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂▃▃▃▇▆▇▇▆▅▄▂▁▁ │1.24      0.87 +- 0.19
    param18             : -0.21 │ ▁▁▁▁▁▁▁▁▁▁▁▂▂▂▂▃▃▃▅▄▅▆▇▆▇▇▇▇▅▅▆▃▂▃▁▁▁ │1.41      0.79 +- 0.26
    param19             : -0.26 │ ▁▁▁▂▂▃▃▃▃▄▃▄▆▅▄▄▇▄▅▄▅▅▃▄▃▃▄▂▂▁▂▁▁▁▁▁▁ │1.83      0.69 +- 0.37
    param20             : -0.35 │ ▁▁▄▇▅▇▄▄▅▄▃▃▃▂▂▂▂▁▂▂▂▁▂▁▁▁▁▁▁▁▁▁▁▁▁ ▁ │3.11      0.62 +- 0.57

real 271,16
user 387,67
sys 417,50

Same as the first with a shrink_factor=2

[ultranest] Explored until L=-5  .52 [-9.2145..-9.2125]*| it/evals=58200/39636350 eff=0.1468% N=600 
[ultranest] Likelihood function evaluations: 39683200
[ultranest] Writing samples and results to disk ...
[ultranest] Writing samples and results to disk ... done
[ultranest]   logZ = -104.2 +- 0.2916
[ultranest] Effective samples strategy satisfied (ESS = 470.7, need >400)
[ultranest] Posterior uncertainty strategy is satisfied (KL: 0.45+-0.08 nat, need <0.50 nat)
[ultranest] Evidency uncertainty strategy wants 598 minimum live points (dlogz from 0.27 to 0.53, need <0.5)
[ultranest]   logZ error budget: single: 0.39 bs:0.29 tail:0.41 total:0.50 required:<0.50
[ultranest] done iterating.

logZ = -104.145 +- 0.597
  single instance: logZ = -104.145 +- 0.393
  bootstrapped   : logZ = -104.159 +- 0.439
  tail           : logZ = +- 0.405
insert order U test : converged: False correlation: 463 iterations
step sampler diagnostic: jump distance 1.09 (should be >1), far enough fraction: 70.60%  (should be >50%)

    param1              : 0.856 │ ▁  ▁▁▁▁▁▁▁▁▂▂▂▃▆▅▅▇▇▇▆▆▅▆▅▃▂▁▁▁▁▁▁▁▁▁ │1.119     0.998 +- 0.028
    param2              : 0.852 │ ▁ ▁ ▁▁▁▁▁▁▁▁▁▂▃▃▄▅▇▇▇▆▆▆▃▃▃▃▁▁▁▁▁▁▁▁▁ │1.114     0.997 +- 0.028
    param3              : 0.872 │ ▁▁▁▁▁▁▁▁▁▁▂▂▃▃▅▅▅▇▆▅▆▃▄▃▂▁▁▁▁▁▁▁▁▁▁ ▁ │1.134     0.998 +- 0.028
    param4              : 0.865 │ ▁ ▁▁▁▁▁▁▁▁▁▁▂▂▂▄▅▄▅▅▅▇▄▅▅▄▂▁▁▁▁▁▁▁▁▁▁ │1.109     0.997 +- 0.028
    param5              : 0.865 │ ▁▁▁▁▁▁▁▁▁▁▁▂▃▂▄▄▇▆▇▇▇▇▆▅▆▃▂▂▁▁▁▁▁▁▁▁▁ │1.113     0.997 +- 0.028
    param6              : 0.850 │ ▁  ▁▁▁▁▁▁▁▁▁▁▂▃▄▄▄▇▅▆▇▅▄▄▃▂▂▁▁▁▁▁▁▁▁▁ │1.116     0.994 +- 0.027
    param7              : 0.715 │ ▁            ▁▁▁▁▁▁▁▁▂▃▃▇▇▆▇▅▄▂▂▁▁▁▁▁ │1.116     0.995 +- 0.027
    param8              : 0.518 │ ▁      ▁     ▁▁      ▁▁▁▁▁▂▄▇▇▅▄▂▁▁▁▁ │1.131     0.996 +- 0.029
    param9              : 0.265 │ ▁       ▁▁        ▁   ▁▁ ▁▁▁▁▃▅▇▅▂▁▁▁ │1.148     0.996 +- 0.029
    param10             : 0.128 │ ▁   ▁      ▁      ▁ ▁▁▁▁▁▁▁▁▁▁▃▇▇▅▁▁▁ │1.145     0.995 +- 0.029
    param11             : -0.065│ ▁ ▁      ▁   ▁  ▁▁  ▁▁▁▁▁▁▁▁▁▁▁▅▇▅▁▁▁ │1.166     0.992 +- 0.032
    param12             : -0.136│ ▁ ▁  ▁ ▁  ▁ ▁▁ ▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▅▇▄▁▁ │1.143     0.989 +- 0.035
    param13             : -0.072│ ▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▄▇▆▂▁▁ │1.155     0.983 +- 0.045
    param14             : -0.108│ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▄▆▇▄▁▁ │1.141     0.971 +- 0.063
    param15             : -0.148│ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▃▅▇▇▆▂▁ │1.136     0.949 +- 0.091
    param16             : -0.19 │ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▃▃▄▇▆▇▅▁▁ │1.15      0.91 +- 0.13
    param17             : -0.17 │ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▃▃▃▄▄▆▆▆▇▆▄▂▁▁ │1.21      0.85 +- 0.19
    param18             : -0.23 │ ▁▁▁▁▁▁▁▁▁▁▁▁▂▁▂▂▄▃▃▃▄▅▅▅▅▇▅▇▆▆▄▄▂▂▁▁▁ │1.35      0.76 +- 0.26
    param19             : -0.23 │ ▁▁▁▃▄▄▄▇▅▅▅▆▇▇▇▇▇▇▇▇▆▅▇▆▄▃▂▆▂▂▂▁▁▁▁▁▁ │1.77      0.65 +- 0.36
    param20             : -0.34 │ ▁▁▃▇▅▅▄▄▄▃▃▃▃▂▃▂▂▁▁▁▂▁▁▁▁▁▁ ▁▁▁▁▁ ▁ ▁ │2.98      0.55 +- 0.50

real 231,81
user 335,97
sys 372,82

Here is the test with a starting scale of 1.0 and the scale adapting procedure:

[ultranest] Explored until L=-2  .25 [-39.0518..-4.8895] | it/evals=78120/78944550 eff=0.0724% N=1200 
[ultranest] Likelihood function evaluations: 79013350
[ultranest] Writing samples and results to disk ...
[ultranest] Writing samples and results to disk ... done
[ultranest]   logZ = -114.1 +- 0.3663
[ultranest] Effective samples strategy satisfied (ESS = 13813.5, need >400)
[ultranest] Posterior uncertainty strategy is satisfied (KL: 0.46+-0.08 nat, need <0.50 nat)
[ultranest] Evidency uncertainty strategy wants 299 minimum live points (dlogz from 0.30 to 0.87, need <0.5)
[ultranest]   logZ error budget: single: 0.29 bs:0.37 tail:0.02 total:0.37 required:<0.50
[ultranest] done iterating.

logZ = -114.137 +- 0.663
  single instance: logZ = -114.137 +- 0.416
  bootstrapped   : logZ = -114.144 +- 0.663
  tail           : logZ = +- 0.025
insert order U test : converged: True correlation: inf iterations
step sampler diagnostic: jump distance 1.10 (should be >1), far enough fraction: 72.56%  (should be >50%)

    param1              : 0.870 │ ▁▁▁▁▁▁▁▁▁▁▂▃▃▄▅▆▇▇▇▇▆▆▅▄▃▂▂▁▁▁▁▁▁▁▁ ▁ │1.127     0.997 +- 0.029
    param2              : 0.863 │ ▁▁ ▁▁▁▁▁▁▁▁▂▂▃▄▅▆▆▇▇▇▇▆▆▄▄▂▂▁▁▁▁▁▁▁▁▁ │1.117     0.997 +- 0.029
    param3              : 0.861 │ ▁▁▁▁▁▁▁▁▁▁▂▂▃▄▅▆▆▇▇▇▇▆▅▄▃▂▂▁▁▁▁▁▁   ▁ │1.134     0.997 +- 0.029
    param4              : 0.854 │ ▁▁▁▁▁▁▁▁▁▁▁▁▂▂▃▄▅▆▆▇▇▇▇▇▅▄▃▃▂▁▁▁▁▁▁▁▁ │1.112     0.998 +- 0.029
    param5              : 0.866 │ ▁▁▁▁▁▁▁▁▁▁▂▂▃▄▅▆▇▇▇▇▇▆▅▄▃▂▂▁▁▁▁▁▁▁▁ ▁ │1.130     0.997 +- 0.029
    param6              : 0.857 │ ▁▁▁▁▁▁▁▁▁▁▁▂▂▃▃▄▅▆▇▇▇▇▇▆▅▄▃▂▂▁▁▁▁▁▁▁▁ │1.114     0.997 +- 0.029
    param7              : 0.814 │ ▁ ▁   ▁▁▁▁▁▁▁▁▁▂▃▄▅▆▇▇▇▇▆▅▄▃▂▁▁▁▁▁▁▁▁ │1.124     0.997 +- 0.029
    param8              : 0.677 │ ▁              ▁▁▁▁▁▁▁▂▃▅▇▇▇▆▄▃▂▁▁▁▁▁ │1.126     0.996 +- 0.029
    param9              : 0.358 │ ▁       ▁      ▁ ▁▁  ▁▁▁▁▁▁▂▄▇▇▅▂▁▁▁▁ │1.158     0.996 +- 0.029
    param10             : 0.108 │ ▁     ▁   ▁     ▁▁▁▁▁▁ ▁▁▁▁▁▁▁▂▆▇▅▂▁▁ │1.146     0.995 +- 0.030
    param11             : 0.013 │ ▁▁   ▁   ▁ ▁▁▁▁▁  ▁▁▁▁▁▁▁▁▁▁▁▁▂▅▇▅▁▁▁ │1.156     0.993 +- 0.031
    param12             : -0.068│ ▁▁  ▁▁▁▁  ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▄▇▅▁▁▁ │1.164     0.990 +- 0.035
    param13             : -0.080│ ▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▃▇▇▃▁▁ │1.146     0.984 +- 0.044
    param14             : -0.154│ ▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▄▇▇▂▁▁ │1.160     0.973 +- 0.059
    param15             : -0.181│ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▃▆▇▅▂▁▁ │1.174     0.953 +- 0.086
    param16             : -0.22 │ ▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▄▅▇▇▅▂▁▁ │1.18      0.92 +- 0.13
    param17             : -0.17 │ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂▃▃▄▅▆▇▇▇▆▄▂▁▁ │1.22      0.86 +- 0.19
    param18             : -0.23 │ ▁▁▁▁▁▁▁▁▁▁▁▂▂▂▂▂▃▃▄▄▅▆▆▇▇▇▇▇▇▅▄▃▂▁▁▁▁ │1.41      0.78 +- 0.26
    param19             : -0.26 │ ▁▁▁▂▄▄▄▄▅▅▅▆▆▇▇▇▇▇▇▇▇▆▆▆▅▄▄▃▂▂▂▁▁▁▁▁▁ │1.80      0.68 +- 0.36
    param20             : -0.33 │ ▁▁▅▇▆▅▅▅▅▄▄▄▃▃▃▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ │3.08      0.59 +- 0.52

real 386,11
user 549,32
sys 583,08

Same as the previous with the jitter on the scale:

[ultranest] Explored until L=-5  4.99 [-10.0719..-10.0706]*| it/evals=63516/34429400 eff=0.1845% N=600 
[ultranest] Likelihood function evaluations: 34429400
[ultranest] Writing samples and results to disk ...
[ultranest] Writing samples and results to disk ... done
[ultranest]   logZ = -113.7 +- 0.2647
[ultranest] Effective samples strategy satisfied (ESS = 409.7, need >400)
[ultranest] Posterior uncertainty strategy is satisfied (KL: 0.46+-0.11 nat, need <0.50 nat)
[ultranest] Evidency uncertainty strategy wants 598 minimum live points (dlogz from 0.22 to 0.61, need <0.5)
[ultranest]   logZ error budget: single: 0.41 bs:0.26 tail:0.41 total:0.48 required:<0.50
[ultranest] done iterating.

logZ = -113.795 +- 0.637
  single instance: logZ = -113.795 +- 0.411
  bootstrapped   : logZ = -113.735 +- 0.491
  tail           : logZ = +- 0.406
insert order U test : converged: True correlation: inf iterations
step sampler diagnostic: jump distance 1.09 (should be >1), far enough fraction: 69.39%  (should be >50%)

    param1              : 0.855 │ ▁  ▁▁▁▁▁▁▁▁▁▂▂▃▄▆▅▆▇▆▆▆▆▇▄▃▄▁▁▁▁▁▁▁▁▁ │1.114     0.999 +- 0.029
    param2              : 0.870 │ ▁▁▁▁▁▁▁▁▁▁▁▂▃▃▃▄▄▅▅▅▇▆▃▄▃▂▂▁▁▁▁▁▁▁▁▁▁ │1.119     0.998 +- 0.028
    param3              : 0.870 │ ▁▁▁▁▁▁▁▁▁▁▁▂▃▃▄▄▅▇▇▆▆▆▆▄▃▄▂▂▂▁▁▁▁▁▁▁▁ │1.115     0.998 +- 0.029
    param4              : 0.864 │ ▁▁▁▁▁▁▁▁▁▁▁▂▂▄▅▄▆▇▆▆▇▇▅▇▄▄▂▁▁▁▁▁▁▁▁ ▁ │1.125     1.000 +- 0.029
    param5              : 0.843 │ ▁  ▁▁▁▁▁▁▁▁▁▂▂▃▄▅▅▆▇▇▇▅▅▄▃▂▁▁▁▁▁▁▁▁ ▁ │1.129     0.997 +- 0.029
    param6              : 0.846 │ ▁▁ ▁▁▁▁▁▁▁▁▁▁▁▂▄▄▅▇▅▆▅▆▆▇▄▃▂▂▁▁▁▁▁▁▁▁ │1.111     0.996 +- 0.029
    param7              : 0.706 │ ▁            ▁▁▁▁▁▁▁▁▂▃▃▅▆▇▇▅▃▂▁▁▁▁▁▁ │1.125     0.996 +- 0.028
    param8              : 0.614 │ ▁   ▁       ▁ ▁  ▁▁▁▁▁▁▁▃▄▅▇▇▅▃▁▁▁▁▁▁ │1.135     0.997 +- 0.028
    param9              : 0.428 │ ▁  ▁    ▁   ▁   ▁  ▁▁▁▁▁▁▁▁▁▃▄▇▄▃▁▁▁▁ │1.131     0.996 +- 0.028
    param10             : 0.182 │ ▁ ▁  ▁        ▁   ▁▁▁▁▁▁▁▁▁▁▁▂▄▇▇▃▁▁▁ │1.148     0.996 +- 0.031
    param11             : -0.005│ ▁▁ ▁    ▁   ▁ ▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▄▇▅▁▁▁ │1.157     0.992 +- 0.031
    param12             : -0.065│ ▁▁▁ ▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▃▇▇▂▁▁ │1.151     0.990 +- 0.036
    param13             : -0.138│ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▄▇▇▂▁▁ │1.162     0.984 +- 0.045
    param14             : -0.116│ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▅▇▆▁▁▁ │1.166     0.972 +- 0.061
    param15             : -0.174│ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▃▅▇▇▂▁▁ │1.159     0.952 +- 0.089
    param16             : -0.16 │ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▃▅▆▆▇▇▂▁▁ │1.18      0.92 +- 0.13
    param17             : -0.18 │ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂▃▅▄▆▆▇▇▇▇▅▁▁▁ │1.24      0.86 +- 0.19
    param18             : -0.19 │ ▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂▂▂▃▃▅▄▄▆▆▆▆▇▅▆▅▇▅▆▂▁▁▁ │1.34      0.79 +- 0.27
    param19             : -0.25 │ ▁▁▁▂▄▄▃▄▄▄▄▇▄▅▆▇▇▆▆▆▇▆▅▅▄▇▅▃▃▆▂▁▁▁▁▁▁ │1.70      0.69 +- 0.37
    param20             : -0.32 │ ▁▁▃▇▇▅▅▅▅▄▄▄▃▄▃▂▂▂▄▃▂▂▁▃▁▁▁▁▁▁▁▁▁▁▁ ▁ │2.65      0.61 +- 0.52

real 270,94
user 386,76
sys 415,04
JohannesBuchner commented 4 months ago

Hi @njzifjoiez,

Great progress here, thanks for the tenacity to stick with it.

I advanced on the unit tests and caught the current version of the code. I added unit tests for the functions used in the sampler and a sanity check for the sampler by itself. The idea of the last one is to run one step of the sampler from a random set of points and check that the new points have all L>Lmin , are in the unit cube and are on the slice defined at the beginning of this iteration. I can add more sanity check there, I just thought of these three points. Let me know if you're good with that or if I should add more stuff there.

Looks good to me, thanks for the update_vectorised_slice_sampler test.

I also found that JAXNS was using a similar method for their slice sampler in the last paper here: https://arxiv.org/abs/2312.11330 They mention in section 3 that they remove the step-out procedure and use the bound of the sampling space as in the default case for the sampler here. Instead of my procedure with a scale, they are shrinking at the midpoint between the initial and proposed points. So I added a new parameter, a shrink_factor, that accelerates the shrinking in the same way. When it is 2, we get the midpoint, but it can be set to another value. I added a condition that it should always be larger than one to accelerate compared to the default case. I think it may be more robust than my initial guess. Let me know what you think; I added new tests at the end of the msg here with the different modes of the sampler with the current version of the code.

Looks very good to me if you find this is working nicely.

I also tried to run the calibrator on my sampler after adding the new things that I saw on the other population step sampler. However, it seems that they are not currently working on it. My test broke when the method check_nsteps and adaptive_nsteps were called in ReactiveNestedCalibrator.run. I try to look at the normal step sampler, but it would be easier if you add them on the population step sampler, it would be surely very similar to what i need to do with this one. I am unsure about what I did for the logstat. I looked at the implementations PopulationRandomWalkSampler and PopulationSliceSampler. I think the first has a typo because 6 elements were added instead of 5.

Each sampler can log whatever it thinks is useful for diagnosis later.

My guess for my sampler was that far_enough, mean_rel_jump should be the same. scale is the scale, but in the default case it is not use as I use the bound of the unit cube, so it is always 1.

OK.

I was wondering about the two last ones. I should have an accept_rate of 1 because we always find new points theoretically. As my while loop has a number of step limits, it may not be the case for a specific step. So i am not sure what I should add here, because If they have not found new points for each of the starting one, the code should exit before. I am not sure of what the efficiency means here too.

I added some comments at the code line to clarify this.

Let me know if I forgot to answer anything!

njzifjoiez commented 4 months ago

I made the modification related to your last comments. Let me know if it's all good for the merge!

JohannesBuchner commented 4 months ago

Lets see what the CI says: https://app.circleci.com/pipelines/github/JohannesBuchner/UltraNest

JohannesBuchner commented 4 months ago

OK!

JohannesBuchner commented 4 months ago

Thanks so much @njzifjoiez, I hope you continue to contribute to UltraNest!

JohannesBuchner commented 4 months ago

I released 5.3.0, please test it.

At least some doc py links seem to not have worked https://johannesbuchner.github.io/UltraNest/ultranest.html#ultranest.popstepsampler.PopulationSimpleSliceSampler

njzifjoiez commented 4 months ago

I ran the tests and some test runs with the Rosenbrock functions, and everything seems to work fine.

My bad for the doc links, I got a lot them wrong. Looking at it, I think i did the same mistake on all of them in the sampler explanation and also for slice_limit parameter.

The quotation mark is misplaced, and I forgot to add ultranest.popstepsampler.. For example, the first non-working link is: `:py:class:PopulationSliceSampler` instead of :py:class:`ultranest.popstepsampler.PopulationSliceSampler`