param

pmrf.parameters.param(value: Any = <dataclasses._MISSING_TYPE object>, *, distribution: AbstractDistribution | None = None, constraint: AbstractConstraint | None = None, scale: float = 1.0, fixed: bool = False) Any

A field specifier for defining the rules of parameters in custom models.

This specifier can be used when declaring custom models inheriting from pmrf.Model. For example, it can be used to enforce constraints/scaling/bounds that are required by the model itself.

Example

Declaring a parameter with a positive constraint and built-in scale:

import pmrf as prf
from pmrf.models import Resistor, Capacitor
from pmrf.constraints import Positive

class RC(prf.Model):
    R: prf.Param = prf.param(constraint=Positive())
    C: prf.Param = prf.param(constraint=Positive(), scale=1e-12)

    def build(self) -> prf.Model:
        return Resistor(self.R) ** Capacitor(self.C)

RC(1.0, 2.0)
# RC(R=1., C=2.e-12)

RC(-1.0, 2.0)
# ValueError: out of bounds
Parameters:
  • value (Any, optional) – The default value of the field.

  • distribution (Optional[AbstractDistribution], optional) – The probability distribution for the parameter. See pmrf.distributions.

  • constraint (Optional[AbstractConstraint], optional) – The constraint to apply to the parameter. See pmrf.constraints.

  • scale (float, optional) – The scaling factor to apply, by default 1.0.

  • fixed (bool, optional) – Whether to freeze the parameter, by default False.

Returns:

An equinox field with a built-in converter for parameter rules.

Return type:

Any