SLCP#

class bayesflow.simulators.SLCP(lower_bound: float = -3.0, upper_bound: float = 3.0, n_obs: int = 4, flatten: bool = True, rng: Generator = None)[source]#

Bases: BenchmarkSimulator

SLCP simulated benchmark See https://arxiv.org/pdf/2101.04653.pdf, Task T.3

Parameters:
lower_bound: float, optional, default: -3.0

The lower bound of the uniform prior.

upper_bound: float, optional, default: 3.0

The upper bound of the uniform prior.

n_obs: int, optional, default: 4

The number of observations to generate from the slcp likelihood.

flatten: bool, optional, default: True

A flag to indicate whather a 1D (flatten=True) or a 2D (flatten=False) representation of the simulated data is returned.

rng: np.random.Generator or None, optional, default: None

An optional random number generator to use.

prior()[source]#

Generates a random draw from a 5-dimensional uniform prior bounded between lower_bound and upper_bound which represents the 5 parameters of the SLCP simulator.

Returns:
paramsnp.ndarray of shape (5, )

A single draw from the 5-dimensional uniform prior.

__call__(**kwargs) dict[str, ndarray]#

Call self as a function.

observation_model(params: ndarray)[source]#

Generates data from the SLCP model designed as a benchmark for a simple likelihood and a complex posterior due to a non-linear pushforward params -> x.

Parameters:
paramsnp.ndarray of shape (params, D)

The location parameters of the Gaussian likelihood.

Returns:
xnp.ndarray of shape (n_obs*2, ) or (n_obs, 2), as indictated by the flatten

boolean flag. The sample of simulated data from the SLCP model.

rejection_sample(batch_shape: tuple[int, ...], predicate: Callable[[dict[str, ndarray]], ndarray], *, axis: int = 0, sample_size: int = None, **kwargs) dict[str, ndarray]#
sample(batch_shape: tuple[int, ...], **kwargs) dict[str, ndarray]#

Runs simulated benchmark and returns batch_size parameter and observation batches

Parameters:
batch_shape: tuple

Number of parameter-observation batches to simulate.

Returns:
dict[str, np.ndarray]: simulated parameters and observables

with shapes (batch_size, …)