InverseKinematics#

class bayesflow.simulators.InverseKinematics(scales: ndarray = None, l1: float = 0.5, l2: float = 0.5, l3: float = 1.0, rng: Generator = None)[source]#

Bases: BenchmarkSimulator

Inverse Kinematics simulated benchmark See: https://arxiv.org/pdf/2101.10763.pdf

Parameters:
scales: np.ndarray of shape (4, ) or None, optional, default: None

The four scales of the Gaussian prior. If None provided, the scales from https://arxiv.org/pdf/2101.10763.pdf will be used: [0.25, 0.5, 0.5, 0.5].

l1: float, optional, default: 0.5

The length of the first segment.

l2: float, optional, default: 0.5

The length of the second segment.

l3: float, optional, default: 1.0

The length of the third segment.

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

An optional random number generator to use.

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

Call self as a function.

prior()[source]#

Generates a random draw from a 4-dimensional Gaussian prior distribution with a spherical convariance matrix. The parameters represent a robot’s arm configuration, with the first parameter indicating the arm’s height and the remaining three are angles.

Returns:
paramsnp.ndarray of shape (4, )

A single draw from the 4-dimensional Gaussian prior.

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

observation_model(params: ndarray)[source]#

Returns the 2D coordinates of a robot arm given parameter vector. The first parameter represents the arm’s height and the remaining three correspond to angles.

Parameters:
paramsnp.ndarray of shape (params, )

The four model parameters which will determine the coordinates

Returns:
xnp.ndarray of shape (2, )

The 2D coordinates of the arm