Simulation Based Inference

Contains the implementations for the simulation-based inference methods

Implements the supported simulation-based inference methods.

class calisim.sbi.implementation.SimulationBasedInferenceMethod(calibration_func: Callable, specification: SimulationBasedInferenceMethodModel, engine: str = 'sbi', implementation: CalibrationWorkflowBase | None = None)[source]

The simulation-based inference method class.

pydantic model calisim.sbi.implementation.SimulationBasedInferenceMethodModel[source]

The simulation-based inference method data model.

Parameters:

BaseModel (CalibrationModel) – The calibration base model class.

Config:
  • arbitrary_types_allowed: bool = True

  • protected_namespaces: tuple = ()

Fields:
field num_simulations: int = 25

The number of simulations to run

calisim.sbi.implementation.get_implementations() dict[str, type[CalibrationWorkflowBase]][source]

Get the calibration implementations for simulation-based inference.

Returns:

The dictionary of

calibration implementations for simulation-based inference.

Return type:

Dict[str, type[CalibrationWorkflowBase]]

SBI

Contains the implementations for simulation-based inference methods using SBI

Implements the supported simulation-based inference methods using the SBI library.

class calisim.sbi.sbi_wrapper.SBISimulationBasedInference(calibration_func: Callable, specification: CalibrationModel, task: str)[source]

The SBI simulation-based inference method class.

analyze() None[source]

Analyze the results of the simulation calibration procedure.

execute() None[source]

Execute the simulation calibration procedure.

LAMPE

Contains the implementations for simulation-based inference methods using LAMPE

Implements the supported simulation-based inference methods using the LAMPE library.

class calisim.sbi.lampe_wrapper.LAMPESimulationBasedInference(calibration_func: Callable, specification: CalibrationModel, task: str)[source]

The LAMPE simulation-based inference method class.

analyze() None[source]

Analyze the results of the simulation calibration procedure.

execute() None[source]

Execute the simulation calibration procedure.

postprocess(samples: Tensor, parameter_spec: list[DistributionModel] | Any | None) Tensor[source]

Reverse normalise the parameters of the simulation. :param samples: The normalised parameters. :type samples: torch.Tensor :param parameter_spec: The parameter specification. :type parameter_spec: list[DistributionModel] | Any | None

Raises:

ValueError – Error raised when an unsupported distribution is provided.

Returns:

The denormalised parameters.

Return type:

torch.Tensor

preprocess(theta: Tensor, parameter_spec: list[DistributionModel] | Any | None) Tensor[source]

Normalise the parameters of the simulation. :param theta: The simulation parameters. :type theta: torch.Tensor :param parameter_spec: The parameter specification. :type parameter_spec: list[DistributionModel] | Any | None

Raises:

ValueError – Error raised when an unsupported distribution is provided.

Returns:

The normalised parameters.

Return type:

torch.Tensor

specify() None[source]

Specify the parameters of the model calibration procedure.

class calisim.sbi.lampe_wrapper.PriorCollection(priors: list[Distribution])[source]

A wrapper around a collection of priors.

sample(batch_shape: tuple = ()) Tensor[source]

Sample from the priors.

Parameters:

batch_shape (tuple, optional) – The batch shape of the sampled priors. Defaults to ().

Returns:

The sampled priors.

Return type:

torch.Tensor