Closed njzifjoiez closed 7 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.
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.
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
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 is2
, 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
andadaptive_nsteps
were called inReactiveNestedCalibrator.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 thelogstat
. I looked at the implementationsPopulationRandomWalkSampler
andPopulationSliceSampler
. 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 always1
.
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 theefficiency
means here too.
I added some comments at the code line to clarify this.
Let me know if I forgot to answer anything!
I made the modification related to your last comments. Let me know if it's all good for the merge!
Lets see what the CI says: https://app.circleci.com/pipelines/github/JohannesBuchner/UltraNest
OK!
Thanks so much @njzifjoiez, I hope you continue to contribute to UltraNest!
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
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`
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
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
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
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:
Here with the jitter+adaptation