# Nested Sampling

This is an implementation of the Nested Sampling by John Skilling, as published in https://projecteuclid.org/euclid.ba/1340370944.

The implementation of the Multi Ellipse proposal distribution is based on the work of Feroz et. al. https://academic.oup.com/mnras/article/398/4/1601/981502.

Our version of the Multi Nest algorithm include a pior repartitioning strategy https://link.springer.com/article/10.1007/s11222-018-9841-3 to efficiently sample unrepresentative priors.

## Usage

`e["Solver"]["Type"] = "Sampler/Nested"`

## Results

These are the results produced by this solver:

Posterior Samples Datase
• Usage: e[“Results”][“Posterior Samples Datase”] = List of Lists of real number

• Description: Samples that approximate the posterior distribution.

Posterior Samples LogPrior Database
• Usage: e[“Results”][“Posterior Samples LogPrior Database”] = List of real number

• Description: Log Priors of Samples in Posterior Samples Database.

Posterior Samples LogLikelihood Database
• Usage: e[“Results”][“Posterior Samples LogLikelihood Database”] = List of real number

• Description: Log Likelihood of Samples in Posterior Samples Database.

Sample Database
• Usage: e[“Results”][“Sample Database”] = List of Lists of real number

• Description: Collection of samples describing the probability distribution.

## Variable-Specific Settings

These are settings required by this module that are added to each of the experiment’s variables when this module is selected.

Lower Bound
• Usage: e[“Variables”][index][“Lower Bound”] = real number

• Description: Specifies the lower bound for the variable’s value.

Upper Bound
• Usage: e[“Variables”][index][“Upper Bound”] = real number

• Description: Specifies the upper bound for the variable’s value.

Initial Value
• Usage: e[“Variables”][index][“Initial Value”] = real number

• Description: Defines the initial value at or around which the algorithm shall start looking for an optimum.

## Configuration

These are settings required by this module.

Number Live Points
• Usage: e[“Solver”][“Number Live Points”] = unsigned integer

• Description: Number of live samples.

Batch Size
• Usage: e[“Solver”][“Batch Size”] = unsigned integer

• Description: Number of samples to discard and replace per generation, maximal number of parallel sample evaluation.

• Usage: e[“Solver”][“Add Live Points”] = True/False

Resampling Method
• Usage: e[“Solver”][“Resampling Method”] = string

• Description: Method to generate new candidates (can be set to either ‘Box’ or ‘Ellipse’, ‘Multi Ellipse’).

Proposal Update Frequency
• Usage: e[“Solver”][“Proposal Update Frequency”] = unsigned integer

• Description: Frequency of resampling distribution update (e.g. ellipse rescaling for Ellipse).

Ellipsoidal Scaling
• Usage: e[“Solver”][“Ellipsoidal Scaling”] = real number

• Description: Scaling factor of ellipsoidal (only relevant for ‘Ellipse’ and ‘Multi Ellipse’ proposal).

## Termination Criteria

These are the customizable criteria that indicates whether the solver should continue or finish execution. Korali will stop when at least one of these conditions are met. The criteria is expressed in C++ since it is compiled and evaluated as seen here in the engine.

Min Log Evidence Delta
• Usage: e[“Solver”][“Min Log Evidence Delta”] = real number

• Description: Minimal difference between estimated remaining log evidence and current logevidence.

• Criteria: `(_k->_currentGeneration > 1) && (_logEvidenceDifference <= _minLogEvidenceDelta)`

Max Effective Sample Size
• Usage: e[“Solver”][“Max Effective Sample Size”] = unsigned integer

• Description: Estimated maximal evidence gain smaller than accumulated evidence by given factor.

• Criteria: `_maxEffectiveSampleSize <= _effectiveSampleSize`

Max Log Likelihood
• Usage: e[“Solver”][“Max Log Likelihood”] = unsigned integer

• Description: Terminates if loglikelihood of sample removed from live set exceeds given value.

• Criteria: `_maxLogLikelihood <= _lStar`

Max Model Evaluations
• Usage: e[“Solver”][“Max Model Evaluations”] = unsigned integer

• Description: Specifies the maximum allowed evaluations of the computational model.

• Criteria: `_maxModelEvaluations <= _modelEvaluationCount`

Max Generations
• Usage: e[“Solver”][“Max Generations”] = unsigned integer

• Description: Determines how many solver generations to run before stopping execution. Execution can be resumed at a later moment.

• Criteria: `_k->_currentGeneration > _maxGenerations`

## Default Configuration

These following configuration will be assigned by default. Any settings defined by the user will override the given settings specified in these defaults.

```{
"Batch Size": 1,
"Ellipsoidal Scaling": 1.0,
"Model Evaluation Count": 0,
"Multivariate Generator": {
"Type": "Multivariate/Normal"
},
"Normal Generator": {
"Mean": 0.0,
"Standard Deviation": 1.0,
"Type": "Univariate/Normal"
},
"Number Live Points": 1500,
"Proposal Update Frequency": 1500,
"Resampling Method": "Ellipse",
"Termination Criteria": {
"Max Effective Sample Size": 10000000.0,
"Max Generations": 10000000000,
"Max Log Likelihood": 10000000.0,
"Max Model Evaluations": 1000000000,
"Min Log Evidence Delta": 0.01
},
"Uniform Generator": {
"Maximum": 1.0,
"Minimum": 0.0,
"Type": "Univariate/Uniform"
},
"Variable Count": 0
}
```

## Variable Defaults

These following configuration will be assigned to each of the experiment variables by default. Any settings defined by the user will override the given settings specified in these defaults.

```{
"Initial Value": -Infinity,
"Lower Bound": -Infinity,
"Upper Bound": Infinity
}
```