SLCPDistractors#

class bayesflow.simulators.SLCPDistractors(lower_bound: float = -3.0, upper_bound: float = 3.0, n_obs: int = 4, n_dist: int = 46, dim: int = 2, mu_scale: float = 15.0, shape_scale: float = 0.01, flatten: bool = True, rng: Generator = None)[source]#

Bases: BenchmarkSimulator

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

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.

n_dist: int, optional, default: 46

The number of distractor to draw from the distractor likelihood.

dim: int, optional, default: 2

The dimensionality of each student-t distribution in the mixture.

mu_scale: float, optional, default: 15.0

The scale of the zero-centered Gaussian prior from which the mean vector of each student-t distribution in the mixture is drawn.

shape_scale: float, optional, default: 0.01

The scale of the assumed np.eye(dim) shape matrix. The default is chosen to keep the scale of the distractors and observations relatively similar.

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.

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. In addition, it outputs uninformative distractor data.

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

The location parameters of the Gaussian likelihood.

Returns:
x: np.ndarray of shape (n_obs*2 + n_dist*2, ) if flatten=True, otherwise

np.ndarray of shape (n_obs + n_dist, 2) if flatten=False

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, …)