parsac.optimize package
Submodules
Module contents
- class parsac.optimize.GaussianLikelihood(source: str, obs_vals: ArrayLike, sd: ArrayLike | None = None, logscale: bool = False, minimum: float | None = None, estimate_scale_factor: bool = False, min_scale_factor: float | None = None, max_scale_factor: float | None = None, scale_factor: float = 1.0, estimate_sd: bool | None = None)
Bases:
TransformSet up a Gaussian likelihood function This typically contributes to the objective function in an optimization experiment.
This function assumes that observations are normally distributed around modelled values, with a standard deviation that can be either provided or estimated from the model-observation differences.
It can also be used to represent observations that are log-normally distributed around modelled values by setting argument
logscaletoTrue. In that case both modelled and observed values are log-transformed.Observations are provided upon initialization, and modelled values are provided when the likelihood is called.
- Parameters:
source – The name of the output that will contain the model values.
obs_vals – The observed values.
sd – The standard deviation of the observed values. If not provided, it will be estimated from the differences betweeen modelled and observed values.
logscale – Whether to log-transform modelled and observed values before calculating the likelihood. This implies the distribution of observations around the modelled values is log-normal.
minimum – The minimum allowed value of the modelled and observed values. Lower values will be clipped to this value. This argument must be provided if
logscaleisTrue. It must then be greater than 0.0.estimate_scale_factor – Whether to estimate the scale factor with which model values are multiplied before comparing to observations.
min_scale_factor – Lower bound of the estimated scale factor.
max_scale_factor – Upper bound of the estimated scale factor.
scale_factor – Fixed scale factor, active only if
estimate_scale_factorisFalse.estimate_sd – Whether to estimate the standard deviation of the observed values. If
None(the default), the standard deviation is estimated ifsdis not provided. If the observations do come with standard deviations, but you want to ignore these and estimate the standard deviation from model-observation differences instead, set this argument toTrue.
- class parsac.optimize.HistogramPlotter(name: str, model_vals: ndarray, obs_vals: ndarray)
Bases:
PlotterHistogram of model-observation differences.
- plot(ax: matplotlib.axes.Axes, logger: Logger) None
- class parsac.optimize.ModelVsObservationPlotter(model_vals: ndarray, obs_vals: ndarray)
Bases:
PlotterCorrelation plot showing model (y) versus observations (x).
- plot(ax: matplotlib.axes.Axes, logger: Logger) None
- class parsac.optimize.Optimization(**kwargs)
Bases:
ExperimentAn optimization experiment.
To configure the experiment, add parameters to calibrate by calling
add_parameter(), and add contributions to the objective function (log likelihood) by callingadd_target().- Parameters:
kwargs – Additional keyword arguments to passed to
Experiment.
- add_target(metric: Comparison, **kwargs: Any) None
Add a contribution to the fitness (log-likelihood) function.
- Parameters:
metric – The metric to add to the fitness function. It is typically produced by a job from
parsac.job.kwargs – Additional keyword arguments to pass to the likelihood function
GaussianLikelihood.
- async get_lnls(values: ndarray[tuple[int, int], dtype[float64]]) ndarray
Calculate the log-likelihood of a parameter set.