pmrf.fitting.BayesianResults
- class pmrf.fitting.BayesianResults(measured=None, initial_model=None, fitted_model=None, solver_results=None, settings=None)[source]
Bases:
FitResultsAbstract base class for results obtained from a Bayesian fitting process.
This class extends FitResults to include methods specific to posterior sampling and distribution training.
- Parameters:
- __init__(measured=None, initial_model=None, fitted_model=None, solver_results=None, settings=None)
Methods
__delattr__(name, /)Implement delattr(self, name).
__dir__()Default dir() implementation.
__eq__(other)Return self==value.
__format__(format_spec, /)Default object formatter.
__ge__(value, /)Return self>=value.
__getattribute__(name, /)Return getattr(self, name).
__gt__(value, /)Return self>value.
__init__([measured, initial_model, ...])__init_subclass__This method is called when a class is subclassed.
__le__(value, /)Return self<=value.
__lt__(value, /)Return self<value.
__ne__(value, /)Return self!=value.
__new__(**kwargs)__reduce__()Helper for pickle.
__reduce_ex__(protocol, /)Helper for pickle.
__repr__()Return repr(self).
__setattr__(name, value, /)Implement setattr(self, name, value).
__sizeof__()Size of object in memory, in bytes.
__str__()Return str(self).
__subclasshook__Abstract classes can override this to customize issubclass().
_decode_recursive(group)_encode_recursive(obj, group)_group_to_dict(group)_read_from_group(group)Internal driver to load full object state.
_read_network(group)_read_settings(group)_save_dict_to_group(d, group)_write_network(group, ntwk)_write_settings(group)_write_to_group(group[, metadata])Internal driver to save full object state.
decode_solver_results(group)Decode solver results from an HDF5 group.
encode_solver_results(group)Encode solver results into an HDF5 group.
fit_posterior([train_dist, equal_weights, ...])Fit a trainable distribution to the posterior samples.
load_hdf(path)Load fit results from an HDF5 file.
plot_s_db([use_initial_model])Plots the S-parameters (Magnitude in dB) of the Measured vs Fitted data.
posterior_samples([equal_weights])Retrieve samples drawn from the posterior distribution.
prior_samples([equal_weights])Retrieve samples drawn from the prior distribution.
save_hdf(path[, metadata])Save the fit results to an HDF5 file.
weights()Retrieve the weights associated with the posterior samples.
Attributes
__annotations____dataclass_fields____dataclass_params____dict____doc____hash____match_args____module____weakref__list of weak references to the object (if defined)
fitted_modelinitial_modelmeasuredsettingssolver_results- abstract prior_samples(equal_weights=False)[source]
Retrieve samples drawn from the prior distribution.
- Parameters:
equal_weights (bool, optional, default=False) – If True, returns unweighted (resampled) samples.
- Returns:
The array of prior samples.
- Return type:
jnp.ndarray
- abstract posterior_samples(equal_weights=False)[source]
Retrieve samples drawn from the posterior distribution.
- Parameters:
equal_weights (bool, optional, default=False) – If True, returns unweighted (resampled) samples.
- Returns:
The array of posterior samples.
- Return type:
jnp.ndarray
- abstract weights()[source]
Retrieve the weights associated with the posterior samples.
- Returns:
Array of sample weights.
- Return type:
jnp.ndarray
- fit_posterior(train_dist=None, equal_weights=False, drift_sigma=0.0, boost_method=None, boost_samples=10000, **train_kwargs)[source]
Fit a trainable distribution to the posterior samples.
- Parameters:
train_dist (TrainableDistributionT or None, optional) – The distribution class to train. If None, defaults to MargarineMAFDistribution.
equal_weights (bool, optional, default=False) – If True, uses equal weights for training; otherwise uses sample weights.
drift_sigma (float, optional, default=0.0) – Standard deviation for drift augmentation to broaden the posterior support.
boost_method (str or None, optional) – Method to boost sample count (‘kde’ or None).
boost_samples (int, optional, default=10000) – Number of samples to generate if boosting is enabled.
**train_kwargs – Additional keyword arguments passed to the distribution’s training method.