Parameter¶
Parameter schema — bounds, transforms, priors, and initial values for a
single parameter. Mirrors ionworkspipeline.Parameter.
Schemas for parameter.
- class ionworks_schema.parameter.Parameter(name, initial_value=None, bounds=None, prior=None, normalize=None, check_bounds=None, check_initial_value=None, initial_guess_distribution=None)¶
Bases:
BaseSchemaA model parameter that is free to move during a data fit.
Wrap any quantity you want the fit to adjust in a
Parameterso the pipeline knows it’s a free variable: its starting value, its plausible range, and (optionally) what you already believe about its likely value. Anything not wrapped in aParameteris treated as a fixed input.Parameters¶
- namestr
The name of the parameter. Should match the name used inside the model (e.g.
"Particle diffusion time [s]").- initial_valuefloat | None, optional
The value the optimiser starts from. If you leave it unset, the midpoint of finite bounds is used (or
1when there are no bounds).- boundstuple[float, float] | list[float] | None, optional
(lower, upper)tuple bracketing where you believe the true value lies. Defaults to no bounds. The upper bound must be strictly greater than the lower bound.- priorDistribution or Prior or None, optional
A probability distribution describing what you already believe about the parameter. Used by Bayesian and regularised fits.
- normalizebool | None, optional
Rescale by the initial value before optimisation so the optimiser sees comparable magnitudes. Defaults to
True.- check_boundsbool | None, optional
Validate the bounds at construction time. Defaults to
True.- check_initial_valuebool | None, optional
Validate that the initial value falls inside the bounds at construction time. Defaults to
True.- initial_guess_distributionDistribution or None, optional
When running multistart fits, this is the distribution the starting points are drawn from. Defaults to a uniform distribution over the bounds.
Examples¶
>>> # build the parameter with bounds, a prior, and a log transform >>> raw = iws.Parameter( ... "Negative particle diffusivity [m2.s-1]", ... initial_value=1e-14, ... bounds=(1e-16, 1e-12), ... prior=iws.stats.LogNormal(mean=-32.2, std=2.0), ... ) >>> param = iws.transforms.Log10(parameter=raw) >>> # slot it into a DataFit >>> obj = iws.objectives.Pulse(data_input="path/to/gitt.csv") >>> fit = iws.DataFit(objectives={"gitt": obj}, parameters={raw.name: param})
Extends:
ionworks_schema.base.BaseSchemaSee also:
ionworkspipeline.Parameter(runtime implementation).- upper_bound_greater_than_lower()¶
Validate that upper bound is greater than lower bound.
- model_config = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'populate_by_name': True, 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].