-
Notifications
You must be signed in to change notification settings - Fork 30
/
README
294 lines (195 loc) · 14 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
MultiNest v 2.17
Farhan Feroz, Mike Hobson
arXiv:0704.3704 & arXiv:0809.3437
Released Mar 2012
---------------------------------------------------------------------------
MultiNest Licence
Users are required to accept to the licence agreement given in LICENCE file.
---------------------------------------------------------------------------
MultiNest library requires lapack library.
The code is MPI compatible. In order to disable the MPI parallelization, remove -DMPI compilation flag.
---------------------------------------------------------------------------
gfortran compiler:
You might need to use the following flag while compiling MultiNest with gfortran compiler to remove the
restriction imposed by gfortran on line length.
-ffree-line-length-none
---------------------------------------------------------------------------
The subtoutine to begin MultiNest are as follows:
subroutine nestRun(mmodal, ceff, nlive, tol, efr, ndims, nPar, nCdims, maxModes, updInt, Ztol, root, seed,
pWrap, feedback, resume, outfile, initMPI, logZero, maxiter, loglike, dumper, context)
logical mmodal !do mode separation?
integer nlive !number of live points
logical ceff !run in constant efficiency mode
double precision tol !evidence tolerance factor
double precision efr !sampling efficiency
integer ndims !number of dimensions
integer nPar !total no. of parameters
integer nCdims !no. of parameters on which clustering should be performed (read below)
integer maxModes !maximum no. of modes (for memory allocation)
integer updInt !iterations after which the output files should be written
double precision Ztol !null log-evidence (read below)
character(LEN=100) root !root for MultiNest output files
integer seed !random no. generator seed, -ve value for seed from the sys clock
integer pWrap[ndims] !wraparound parameters?
logical feedback !need update on sampling progress?
logical resume !resume from a previous run?
logical outfile !write output files?
logical initMPI !initialize MPI routines?, relevant only if compiling with MPI
!set it to F if you want your main program to handle MPI initialization
double precision logZero !points with loglike < logZero will be ignored by MultiNest
integer maxiter !max no. of iterations, a non-positive value means infinity. MultiNest will terminate if either it
!has done max no. of iterations or convergence criterion (defined through tol) has been satisfied
loglike(Cube,ndims,nPar,lnew) !subroutine which gives lnew=loglike(Cube(ndims))
dumper(nSamples,nlive,nPar,physLive,posterior,paramConstr,maxloglike,logZ,c) !subroutine called after every updInt*10 iterations with the posterior
!distribution, parameter constraints, max loglike & log evidence values
integer context !not required by MultiNest, any additional information user wants to pass
---------------------------------------------------------------------------
likelihood routine: slikelihood(Cube,ndims,nPar,lnew,context)
Cube(1:nPar) has nonphysical parameters
scale Cube(1:n_dim) & return the scaled parameters in Cube(1:n_dim) & additional parameters that you want to
returned by MultiNest along with the actual parameters in Cube(n_dim+1:nPar)
Return the log-likelihood in lnew
---------------------------------------------------------------------------
dumper routine: dumper(nSamples,nlive,nPar,physLive,posterior,paramConstr,maxloglike,logZ,logZerr,context)
This routine is called after every updInt*10 iterations & at the end of the sampling allowing the posterior
distribution & parameter constraints to be passed on to the user in the memory. The argument are as follows:
nSamples = total number of samples in posterior distribution
nlive = total number of live points
nPar = total number of parameters (free + derived)
physLive(nlive, nPar+1) = 2D array containing the last set of live points (physical parameters plus derived parameters) along with their loglikelihood values
posterior(nSamples, nPar+2) = posterior distribution containing nSamples points. Each sample has nPar parameters (physical + derived) along with the their loglike
value & posterior probability
paramConstr(1, 4*nPar):
paramConstr(1, 1) to paramConstr(1, nPar) = mean values of the parameters
paramConstr(1, nPar+1) to paramConstr(1, 2*nPar) = standard deviation of the parameters
paramConstr(1, nPar*2+1) to paramConstr(1, 3*nPar) = best-fit (maxlike) parameters
paramConstr(1, nPar*4+1) to paramConstr(1, 4*nPar) = MAP (maximum-a-posteriori) parameters
maxLogLike = maximum loglikelihood value
logZ = log evidence value
logZerr = error on log evidence value
context not required by MultiNest, any additional information user wants to pass
The 2D arrays are Fortran arrays which are different to C/C++ arrays. In the example dumper routine provided with C & C++
eggbox examples, the Fortran arrays are copied on to C/C++ arrays.
---------------------------------------------------------------------------
Tranformation from hypercube to physical parameters:
MultiNest native space is unit hyper-cube in which all the parameter are uniformly distributed in [0, 1]. User
is required to transform the hypercube parameters to physical parameters. This transformation is described in
Sec 5.1 of arXiv:0809.3437. The routines to tranform hypercube parameters to most commonly used priors are
provided in module priors (in file priors.f90).
---------------------------------------------------------------------------
Checkpointing:
MultiNest is able to checkpoint. It creates [root]resume.dat file & stores information in it after every
updInt iterations to checkpoint, where updInt is set by the user. If you don't want to resume your program from
the last run run then make sure that you either delete [root]resume.dat file or set the parameter resume to F
before starting the sampling.
---------------------------------------------------------------------------
Periodic Boundary Conditions:
In order to sample from parameters with periodic boundary conditions (or wraparound parameters), set pWrap[i],
where i is the index of the parameter to be wraparound, to a non-zero value. If pWrap[i] = 0, then the ith
parameter is not wraparound.
---------------------------------------------------------------------------
Constant Efficiency Mode:
If ceff is set to T, then the enlargement factor of the bounding ellipsoids are tuned so that the sampling
efficiency is as close to the target efficiency (set by efr) as possible. This does mean however, that the
evidence value may not be accurate.
---------------------------------------------------------------------------
Sampling Parameters:
The recommended paramter values to be used with MultiNest are described below. For detailed description please
refer to the paper arXiv:0809.3437
nPar:
Total no. of parameters, should be equal to ndims in most cases but if you need to store some additional
parameters with the actual parameters then you need to pass them through the likelihood routine.
efr:
defines the sampling efficiency. 0.8 and 0.3 are recommended for parameter estimation & evidence evalutaion
respectively.
tol:
A value of 0.5 should give good enough accuracy.
nCdims:
If mmodal is T, MultiNest will attempt to separate out the modes. Mode separation is done through a clustering
algorithm. Mode separation can be done on all the parameters (in which case nCdims should be set to ndims) & it
can also be done on a subset of parameters (in which case nCdims < ndims) which might be advantageous as
clustering is less accurate as the dimensionality increases. If nCdims < ndims then mode separation is done on
the first nCdims parameters.
Ztol:
If mmodal is T, MultiNest can find multiple modes & also specify which samples belong to which mode. It might be
desirable to have separate samples & mode statistics for modes with local log-evidence value greater than a
particular value in which case Ztol should be set to that value. If there isn't any particularly interesting
Ztol value, then Ztol should be set to a very large negative number (e.g. -1.d90).
---------------------------------------------------------------------------
Progress Monitoring:
MultiNest produces [root]physlive.dat & [root]ev.dat files after every updInt iterations which can be used to
monitor the progress. The format & contents of these two files are as follows:
[root]physlive.dat:
This file contains the current set of live points. It has nPar+2 columns. The first nPar columns are the ndim
parameter values along with the (nPar-ndim) additional parameters that are being passed by the likelihood
routine for MultiNest to save along with the ndim parameters. The nPar+1 column is the log-likelihood value &
the last column is the node no. (used for clustering).
[root]ev.dat:
This file contains the set of rejected points. It has nPar+3 columns. The first nPar columns are the ndim
parameter values along with the (nPar-ndim) additional parameters that are being passed by the likelihood
routine for MultiNest to save along with the ndim parameters. The nPar+1 column is the log-likelihood value,
nPar+2 column is the log(prior mass) & the last column is the node no. (used for clustering).
---------------------------------------------------------------------------
Posterior Files:
These files are created after every updInt*10 iterations of the algorithm & at the end of sampling.
MultiNest will produce five posterior sample files in the root, given by the user, as following
[root].txt
Compatable with getdist with 2+nPar columns. Columns have sample probability, -2*loglikehood, parameter values.
Sample probability is the sample prior mass multiplied by its likelihood & normalized by the evidence.
[root]post_separate.dat
This file is only created if mmodal is set to T. Posterior samples for modes with local log-evidence value
greater than Ztol, separated by 2 blank lines. Format is the same as [root].txt file.
[root]stats.dat
Contains the global log-evidence, its error & local log-evidence with error & parameter means & standard
deviations as well as the best fit & MAP parameters of each of the mode found with local log-evidence > Ztol.
[root]post_equal_weights.dat
Contains the equally weighted posterior samples. Columns have parameter values followed by loglike value.
[root]summary.txt
There is one line per mode with nPar*4+2 values in each line in this file. Each line has the following values
in its column mean parameter values, standard deviations of the parameters, bestfit (maxlike) parameter values,
MAP (maximum-a-posteriori) parameter values, local log evidence, maximum loglike value
---------------------------------------------------------------------------
C/C++ Interface:
C interface to MultiNest is provided in header file multinest.h in example_eggboxC directory.
C++ interface to MultiNest is provided in header file multinest.h in example_eggboxC++ directory.
You might need to check the symbol table for your platform (nm libnest3.a | grep nestrun) & edit
multinest.h file to define NESTRUN.
---------------------------------------------------------------------------
Toy Problems
There are 8 toy programs included with MultiNest.
example_obj_detect: The object detection problem discussed in arXiv:0704.3704. The positions, amplitudes &
widths of the Gaussian objects can be modified through params.f90 file. Sampling parameters are also set in
params.f90.
example_gauss_shell: The Gaussian shells problem discussed in arXiv:0809.3437. The dimensionality, positions and
thickness of these shells can be modified through params.f90 file. Sampling parameters are also set in
params.f90.
example_gaussian: The Gaussian shells problem discussed in arXiv:1001.0719. The dimensionality of the problem can
be modified through params.f90 file. Sampling parameters are also set in params.f90.
example_eggboxC/example_eggboxC++: The C/C++ interface includes the egg box problem discussed in arXiv:0809.3437.
The toy problem and sampling parameters are set in eggbox.c & eggbox.cc files.
example_ackley: The Ackley mimimization problem (see T. Bäck, Evolutionary Algorithms in Theory and Practice,
Oxford University Press, New York (1996).)
example_himmelblau: The Himmelblau's minimization problem. (see http://en.wikipedia.org/wiki/Himmelblau's_function)
example_rosenbrock: Rosenbrock minimization problem. (see http://en.wikipedia.org/wiki/Rosenbrock_function)
example_gaussian: Multivariate Gaussian with uncorrelated paramters.
---------------------------------------------------------------------------
Build through CMake
There is a minimal CMake file called CMakeLists.txt included (courtesy of Brian Kloppenborg). It can be used as follows:
cmake CMakeLists.txt
make
---------------------------------------------------------------------------
Common Problems:
Problem: MultiNest crashes after segmentation fault.
Solution: Try increasing the stack size (ulimit -s unlimited on Linux) & resume your job.
Problem: Output files (.txt & post_equal_weights.dat) files have very few (of order tens) points.
Solution: If tol is set to a reasonable value (tol <= 1) & the job hasn't finished then it is possible for these files to
have very few points in them. If even after the completion of job these files have very few points then increase the stack
size (ulimit -s unlimited on Linux) & resume the job again.
Problem: Not all modes are being reported in the stats file.
Solution: stats file reports all the modes with local log-evidence value greater than Ztol. Set Ztol to a very large
negative number (e.g. -1.d90) in order for the stats file to report all the modes found.
Problem: Compilation fails with error something like 'can not find nestrun function'.
Solution: Check the symbol table for your platform (nm libnest3.a | grep nestrun) & edit multinest.h file to define NESTRUN
appropriately.
---------------------------------------------------------------------------