TwoMoons#
- class bayesflow.simulators.TwoMoons(lower_bound: float = -1.0, upper_bound: float = 1.0, rng: Generator = None)[source]#
Bases:
BenchmarkSimulator
Two moons simulated benchmark. See: https://arxiv.org/pdf/2101.04653.pdf, Task T.8
- Parameters:
- lower_bound: float, optional, default: -1.0
The lower bound of the uniform prior
- upper_bound: float, optional, default: 1.0
The upper bound of the uniform prior
- rng: np.random.Generator or None, optional, default: None
An option random number generator to use
- prior()[source]#
Generates a random draw from a 2-dimensional uniform prior bounded between lower_bound and upper_bound which represents the two parameters of the two moons simulator.
- Returns:
- params: np.ndarray of shape (2, )
A single draw from the 2-dimensional uniform prior.
- observation_model(params: ndarray)[source]#
Implements data generation from the two-moons model with a bimodal posterior.
- Parameters:
- params: np.ndarray of shape (2, )
The vector of two model parameters.
- Returns:
- observables: np.ndarray of shape (2, )
The 2D vector generated from the two moons simulator.
- 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, …)
- sample_batched(batch_shape: tuple[int, ...], *, sample_size: int, **kwargs)#
Sample the desired number of simulations in smaller batches.
Limited resources, especially memory, can make it necessary to run simulations in smaller batches. The number of samples per simulated batch is specified by sample_size.