Standard sampler configuration#

Important

Some of settings discussed here only apply to standard nessai not i-nessai. For i-nessai see Importance nested sampler

There are various settings in nessai which can be configured. These can be grouped in to general settings and proposal settings. The former controls general aspects of the sampler such as the model being sampler or how many live points are used. The latter affect the proposal process and how new points are drawn.

All of the settings are controlled when creating an instance of FlowSampler. The most important settings to consider when using nessai are the reparameterisations used for the proposals.

Key settings#

The most important settings to consider when using nessai with the default FlowProposal are:

  • reset_flow (default False): Whether to reset the normalising flow after each time it is trained. If an integer is specified, the flow is reset after every nth time it is trained. This becomes increasingly important for high dimensional problems or problems where the shape of the likelihood changes significantly as the sampling progresses. We recommend trying values between 1 and 16.

  • volume_fraction (default 0.95): Fractional value used to truncated the normalising flow latent space when drawing new samples. Lower values are more prone to over-constraining contours whilst higher values can lead to inefficient sampling. If the diagnostics indicate the results are over-constrained, increasing this value may help. We recommend trying values between 0.95 and 0.99.

  • nlive (default 2000): Number of live points to use. Increasing this value will lead to more accurate evidence estimates and better exploration of complex, high-dimensional posteriors, but will also increase the runtime. It can also reduce over-constraining since the flow has more sample to learn from.

General configuration#

These are general settings which apply to the whole algorithm and are parsed to NestedSampler. However some of these settings, such as training_frequency which defines how often the proposal method is retrained, will affect the normalising flow used in the proposal class.

Proposal configuration#

The proposal configuration includes a variety of settings ranging from the hyper-parameters for the normalising flow to the size of pool used to store new samples. This also includes the reparameterisations which are essential to efficient sampling. All the available settings are listed below and there are dedicated pages that explain how to configure the reparmeterisations and normalising flows.

class nessai.proposal.flowproposal.FlowProposal(model, poolsize=None, latent_prior=None, latent_temperature=None, constant_volume_mode=None, volume_fraction=None, fuzz=None, fixed_radius=None, radius_mode=None, drawsize=None, truncate_log_q=False, expansion_fraction=None, min_radius=None, max_radius=None, compute_radius_with_all=None, enforce_likelihood_threshold=False, truncation_method=None, truncation_methods=None, truncation_kwargs=None, **kwargs)#

Proposal that samples in latent space using the trained flow.

Parameters:
modelnessai.model.Model

The model to use for the proposal.

poolsizeint, optional

The number of samples to draw from the flow when populating the pool.

latent_priorstr, optional

The prior to use for the latent space. This argument is deprecated and only ‘flow’ is supported.

latent_temperaturefloat, optional

The temperature to use for the latent space. If None, no scaling is applied.

constant_volume_modebool, optional

Whether to use constant volume mode for the latent radius. This argument is deprecated and should be configured via truncation_methods and truncation_kwargs instead.

volume_fractionfloat, optional

The volume fraction to use for the latent radius. This argument is deprecated and should be configured via truncation_methods and truncation_kwargs instead.

fuzzfloat, optional

The fuzz to use for the latent radius. This argument is deprecated and should be configured via truncation_methods and truncation_kwargs instead.

fixed_radiusfloat, optional

The fixed radius to use for the latent radius. This argument is deprecated and should be configured via truncation_methods and truncation_kwargs instead.

radius_modestr, optional

The radius mode to use for the latent radius. This argument is deprecated and should be configured via truncation_methods and truncation_kwargs instead.

drawsizeint, optional

The number of samples to draw from the flow when populating the pool.

truncate_log_qbool, optional

Whether to truncate the log q values when populating the pool. This argument is deprecated and should be configured via truncation_methods and truncation_kwargs instead.

expansion_fractionfloat, optional

The expansion fraction to use for the latent radius. This argument is deprecated and should be configured via truncation_methods and truncation_kwargs instead.

min_radiusfloat, optional

The minimum radius to use for the latent radius. This argument is deprecated and should be configured via truncation_methods and truncation_kwargs instead.

max_radiusfloat, optional

The maximum radius to use for the latent radius. This argument is deprecated and should be configured via truncation_methods and truncation_kwargs instead.

compute_radius_with_allbool, optional

Whether to compute the latent radius using all samples. This argument is deprecated and should be configured via truncation_methods and truncation_kwargs instead.

enforce_likelihood_thresholdbool, optional

Whether to enforce a likelihood threshold when populating the pool. This argument is deprecated and should be configured via truncation_methods and truncation_kwargs instead.

truncation_methodstr, optional

The truncation method to use when populating the pool.

truncation_methodslist of str, optional

The truncation methods to use when populating the pool.

truncation_kwargsdict, optional

The keyword arguments to use for the truncation methods when populating the pool. When using truncation_methods, the keys of this dictionary should match the names of the truncation methods.

**kwargs

Additional keyword arguments to pass to the base class.

Other proposals#

nessai also includes variations on the main FlowProposal class:

  • nessai.gw.proposal.GWFlowProposal as version of FlowProposal that includes specific reparameterisations for gravitational-wave inference.

  • nessai.proposal.augmented.AugmentedFlowProposal this proposal is designed for highly multimodal likelihoods where the standard proposal can break down. It is based around using Augmented Normalising Flows which introduce extra augment dimensions. See the documentation for further details.