bootstrap_comparison#

bayesflow.diagnostics.bootstrap_comparison(observed_samples: ndarray, reference_samples: ndarray, comparison_fn: Callable[[Tensor, Tensor], Tensor], num_null_samples: int = 100) tuple[float, ndarray][source]#

Computes the distance between observed and reference samples and generates a distribution of null sample distances by bootstrapping for hypothesis testing.

Parameters:
observed_samplesnp.ndarray)

Observed samples, shape (num_observed, …).

reference_samplesnp.ndarray

Reference samples, shape (num_reference, …).

comparison_fnCallable[[Tensor, Tensor], Tensor]

Function to compute the distance metric.

num_null_samplesint

Number of null samples to generate for hypothesis testing. Default is 100.

Returns:
distance_observedfloat

The distance value between observed and reference samples.

distance_nullnp.ndarray

A distribution of distance values under the null hypothesis.

Raises:
ValueError
  • If the number of number of observed samples exceeds the number of reference samples

  • If the shapes of observed and reference samples do not match on dimensions besides the first one.