summary_space_comparison#
- bayesflow.diagnostics.summary_space_comparison(observed_data: ~collections.abc.Mapping[str, ~numpy.ndarray], reference_data: ~collections.abc.Mapping[str, ~numpy.ndarray], approximator: ~bayesflow.approximators.continuous_approximator.ContinuousApproximator, num_null_samples: int = 100, comparison_fn: ~collections.abc.Callable = <function maximum_mean_discrepancy>, **kwargs) tuple[float, ndarray] [source]#
Computes the distance between observed and reference data in the summary space and generates a distribution of distance values under the null hypothesis to assess model misspecification.
By default, the Maximum Mean Discrepancy (MMD) is used as a distance function.
[1] M. Schmitt, P.-C. Bürkner, U. Köthe, and S. T. Radev, “Detecting model misspecification in amortized Bayesian inference with neural networks,” arXiv e-prints, Dec. 2021, Art. no. arXiv:2112.08866. URL: https://arxiv.org/abs/2112.08866
- Parameters:
- observed_datadict[str, np.ndarray]
Dictionary of observed data as NumPy arrays, which will be preprocessed by the approximators adapter and passed through its summary network.
- reference_datadict[str, np.ndarray]
Dictionary of reference data as NumPy arrays, which will be preprocessed by the approximators adapter and passed through its summary network.
- approximatorContinuousApproximator
An instance of
ContinuousApproximator
used to compute summary statistics from the data.- num_null_samplesint, optional
Number of null samples to generate for hypothesis testing. Default is 100.
- comparison_fnCallable, optional
Distance function to compare the data in the summary space.
- **kwargsdict
Additional keyword arguments for the adapter and sampling process.
- Returns:
- distance_observedfloat
The MMD value between observed and reference summaries.
- distance_nullnp.ndarray
A distribution of MMD values under the null hypothesis.
- Raises:
- ValueError
If approximator is not an instance of ContinuousApproximator or does not have a summary network.