fit_sample

pmrf.fitting.fit_sample(model: Model, data: Array | Network | NetworkCollection, frequency: Frequency | None = None, solver: AbstractSampler = PolyChord(nlives={}), *, features: str | list[str] | Callable = 's', likelihood_fn: Callable[[Array], AbstractDistribution] | list[Callable[[Array], AbstractDistribution]] = None, discrepancy_fn: Callable[[Array, Array], AbstractDistribution] | None = None, **kwargs) FitResult

Conditions an RF model on measured data using Bayesian sampling.

This high-level function handles data format formatting (e.g., extracting arrays from scikit-rf Networks) and forwards to pmrf.infer.sample().

Parameters:
  • model (Model) – The RF model to fit.

  • data (jnp.ndarray | skrf.Network | NetworkCollection) – The data to condition on. Can either be a JAX array, a skrf.Network, or a pmrf.NetworkCollection.

  • frequency (Frequency | None, default=None) – The frequency sweep. Required if data is a raw array; otherwise automatically extracted from the Network object.

  • solver (Solver, default=PolyChord()) – The sampler to use. Currently, only inferix.PolyChord from Inferix is supported.

  • features (str | list[str] | Callable[[Model, Frequency], jnp.ndarray], default='s') – The RF features to condition on. Can either be function, a callable PyTree with optional parameters, or a string, in which case a ‘feature’ evaluator is created (see pmrf.evaluators.Feature). Defaults to all S-parameters.

  • likelihood_fn (Callable[[jnp.ndarray], dist.AbstractDistribution], optional) – The likelihood function, which accepts a model prediction (in event space) and returns a distribution representing the probability of observing the data. Can be a function or a callable PyTree with optional parameters. See pmrf.likelihoods for common likelihoods. Defaults to None, in which case pmrf.likelihoods.GaussianLikelihood is used.

  • discrepancy_fn (Callable[[jnp.ndarray, jnp.ndarray], jnp.ndarray | dist.AbstractDistribution], optional) – A discrepancy function, which models the discrepancy between the model and measured data. Can either be a function, or a callable PyTree with optional parameters. To use a Gaussian process as a discrepancy model, see pmrf.discrepancy_models.GaussianProcess.

  • **kwargs (dict) – Additional keyword arguments passed to the underlying solver.

Returns:

The result containing the model maximum likelikhood estimate model with an empirical posterior.

Return type:

FitResult