Utils

Heat capacity

nested_sampling.utils.compute_heat_capacity(energies, nreplicas, npar=1, ndof=0, Tmin=0.1, Tmax=1.0, nT=100, live_replicas=False)[source]

compute the heat capacity and average energies from the energy levels of a nested sampling run

Parameters :

energies: nparray of floats

the array of energy levels which is the main result of a nested sampling run. These are stored in NestedSampling.max_energies

nreplicas : int

npar : int

the number of processors uses in a the nested sampling run. This changes the phase space compression factor between the energies.

ndof : int

number of degrees of freedom in the system being studied. This is used to add in the contribution from the momentum degrees of freedom. If this is not passed the heat capacity will be off by an additive constant.

Tmin, Tmax : float

minimum and maximum temperatures

nT : int

number of temperatures at which to compute the heat capacity

live_replicas : bool

if True then the last nreplcas energies are the sorted energies of the live replicas at the end of the nested sampling run.

Returns :

T : array of temperatures

Cv : array of heat capacities (including the momentum degrees of freedom)

U : the mean energy

U : the mean of the (energy squared)

Error analysis

class nested_sampling.utils._jackknife_variance(energies, nsubsets, K, Tmin, Tmax, nT, P, ndof, block, live)[source]

Bases: object

Methods

Cv_singles
__call__
jack_Cv_averages
jack_Cv_moments
jack_Cv_stdev
jack_E_averages
split_energies
split_energies_block
split_energies_randomly
Cv_singles(Esplit)[source]

returns the single Cvs

jack_Cv_averages(EJack)[source]

returns the M(=self.nsubsets) Cv Jackknife averages (from the combined subsets)

jack_Cv_moments(CvJack)[source]

return Cv expectation value from the Jackknife averages of Cv

jack_Cv_stdev(CvJack)[source]

returns the stdev associated with the heat capacity, it calculates the variance of the Jackknife estimate and then from this finds the standard deviation of the heat capacity estimate obtained from the sample average

jack_E_averages(Esplit)[source]

return array of Jacknife averages (more like combined subsets than averages):

split_energies()[source]

returns the correct type of energy subsets, as chosen by the user

split_energies_block()[source]

split the array of energies into n subsets of size n/K as provided

split_energies_randomly()[source]

split the array of energies into n subsets of size n/K randomly

nested_sampling.utils.run_jackknife_variance(energies, nsubsets, K, Tmin, Tmax, nT, P, ndof, block, live)[source]

returns the stdev calculated by jackknifing

class nested_sampling.utils._alpha_variance(energies, nsubsets, K, Tmin, Tmax, nT, P, ndof, live)[source]

Bases: object

Methods

Cv_moments
Cv_singles
Cv_stdev
__call__
jack_Cv_averages
jack_alpha_averages
make_random_alpha_list
sample_alphas
Cv_moments(CvJack)[source]

return Cv expectation value from the Cvs

Cv_singles(alpha_sets)[source]

returns the single Cvs

Cv_stdev(CvJack)[source]

returns the stdev associated with the heat capacity, it calculates the variance of the estimates and then from this finds the standard deviation of the heat capacity estimate obtained from the heat capacity average

jack_Cv_averages(alphaJack)[source]

returns the M(=self.nsubsets) Cv Jackknife averages

jack_alpha_averages(alpha_sets)[source]

return array of Jacknife averages:

make_random_alpha_list()[source]
sample_alphas()[source]

create nsubsets of sampled compression factors

nested_sampling.utils.run_alpha_variance(energies, nsubsets, K, Tmin, Tmax, nT, P, ndof, live)[source]

returns the stdev calculated by jackknifing

General

class nested_sampling.utils.Result[source]

Bases: dict

Represents the optimization result.

Notes

There may be additional attributes not listed above depending of the specific solver. Since this class is essentially a subclass of dict with attribute accessors, one can see which attributes are available using the keys() method.

Attributes

x (ndarray) The solution of the optimization.
success (bool) Whether or not the optimizer exited successfully.
status (int) Termination status of the optimizer. Its value depends on the underlying solver. Refer to message for details.
message (str) Description of the cause of the termination.
fun, jac, hess (ndarray) Values of objective function, Jacobian and Hessian (if available).
nfev, njev, nhev (int) Number of evaluations of the objective functions and of its Jacobian and Hessian.
nit (int) Number of iterations performed by the optimizer.
maxcv (float) The maximum constraint violation.

Methods

clear(() -> None.  Remove all items from D.)
copy(() -> a shallow copy of D)
fromkeys(...) v defaults to None.
get((k[,d]) -> D[k] if k in D, ...)
has_key((k) -> True if D has a key k, else False)
items(() -> list of D’s (key, value) pairs, ...)
iteritems(() -> an iterator over the (key, ...)
iterkeys(() -> an iterator over the keys of D)
itervalues(...)
keys(() -> list of D’s keys)
pop((k[,d]) -> v, ...) If key is not found, d is returned if given, otherwise KeyError is raised
popitem(() -> (k, v), ...) 2-tuple; but raise KeyError if D is empty.
setdefault((k[,d]) -> D.get(k,d), ...)
update(([E, ...) If E present and has a .keys() method, does: for k in E: D[k] = E[k]
values(() -> list of D’s values)
viewitems(...)
viewkeys(...)
viewvalues(...)
nested_sampling.utils.get_energies(fnames, block=False, live=False)[source]

read energies from a list of file names, append the live replicas and return as one list

Table Of Contents