Parameter

Parameter schema — bounds, transforms, priors, and initial values for a single parameter.

Schemas for parameter.

class ionworks.pipeline.parameter.Parameter(name, initial_value=None, bounds=None, prior=None, normalize=None, check_bounds=None, check_initial_value=None, initial_guess_distribution=None)[source]

Bases: BaseSchema

A model parameter that is free to move during a data fit.

Wrap any quantity you want the fit to adjust in a Parameter so 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 a Parameter is treated as a fixed input.

Parameters:
  • name (str) – The name of the parameter. Should match the name used inside the model (e.g. "Particle diffusion time [s]").

  • initial_value (float | None, optional) – The value the optimiser starts from. If you leave it unset, the midpoint of finite bounds is used (or 1 when there are no bounds).

  • bounds (tuple[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.

  • prior (Distribution or Prior or None, optional) – A probability distribution describing what you already believe about the parameter. Used by Bayesian and regularised fits.

  • normalize (bool | None, optional) – Rescale by the initial value before optimisation so the optimiser sees comparable magnitudes. Defaults to True.

  • check_bounds (bool | None, optional) – Validate the bounds at construction time. Defaults to True.

  • check_initial_value (bool | None, optional) – Validate that the initial value falls inside the bounds at construction time. Defaults to True.

  • initial_guess_distribution (Distribution 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 = iw.pipeline.Parameter(
...     "Negative particle diffusivity [m2.s-1]",
...     initial_value=1e-14,
...     bounds=(1e-16, 1e-12),
...     prior=iw.pipeline.stats.LogNormal(mean=-32.2, std=2.0),
... )
>>> param = iw.pipeline.transforms.Log10(parameter=raw)
>>> # slot it into a DataFit
>>> obj = iw.pipeline.objectives.Pulse(
...     data_input="path/to/gitt.csv", options={"model": "SPM"}
... )
>>> fit = iw.pipeline.DataFit(objectives={"gitt": obj}, parameters={raw.name: param})
name: str
initial_value: int | float | None
bounds: tuple[int | float, int | float] | list[int | float] | None
prior: Any | None
normalize: bool | None
check_bounds: bool | None
check_initial_value: bool | None
initial_guess_distribution: Any | None
upper_bound_greater_than_lower()[source]

Validate that upper bound is greater than lower bound.

model_config = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'populate_by_name': True, 'validate_assignment': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) → None

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.