deerlab.Parameter

class Parameter(name=None, parent=None, idx=None, description=None, par0=None, frozen=False, lb=-inf, ub=inf, value=None, unit=None, linear=False)[source]

Represents a model parameter or a single parameter vector.

Attributes:
namestring

Name of the parameter

descriptionstring

Description of the parameter

unitstring

Physical unit of the parameter

par0float or array_like

Value at which to initialize the parameter at the start of a fit routine. Must be specified in the model or latest upon fitting.

lbfloat or array_like

Lower bound of the parameter. If not specified it is assumed to unbounded.

ubfloat or array_like

Upper bound of the parameter. If not specified it is assumed to unbounded.

linearboolean

Describes whether the model behaves linearly with respect to the parameter.

frozenboolean

Describes whether the parameter will be frozen at a specific value during a fit.

valuefloat

Value at which the parameter will be frozen during a fit.

Methods table

__init__([name, parent, idx, description, ...])

Construct a new parameter object.

freeze(value)

Freeze a parameter during a fit/optimization to a given value.

set(**attributes)

Set one or multiple attributes for a parameter.

setas(parameter)

Copy all attributes from an input parameter to the current parameter.

unfreeze()

Release a frozen parameter's value during a fit/optimization.

Methods

Parameter.__init__(name=None, parent=None, idx=None, description=None, par0=None, frozen=False, lb=-inf, ub=inf, value=None, unit=None, linear=False)[source]

Construct a new parameter object.

Parameters:
namestr, optional

Name of the parameter.

parentobject, optional

Reference to the parent object that contains the parameter.

idxint or list of int, optional

Indices of the parameter in the parent object.

descriptionstr, optional

Description of the parameter.

par0float or array_like, optional

Value at which to initialize the parameter at the start of a fit routine. Must be specified in the model or latest upon fitting.

frozenbool, optional

Whether the parameter will be frozen at a specific value during a fit. Default is False.

lbfloat or array_like, optional

Lower bound of the parameter. If not specified, it is assumed to be unbounded. Default is -inf.

ubfloat or array_like, optional

Upper bound of the parameter. If not specified, it is assumed to be unbounded. Default is inf.

valuefloat, optional

Value at which the parameter will be frozen during a fit.

unitstr, optional

Physical unit of the parameter.

linearbool, optional

Whether the model behaves linearly with respect to the parameter. Default is False.

Parameter.freeze(value)[source]

Freeze a parameter during a fit/optimization to a given value.

This method allows the user to freeze a parameter during optimization to a specific value. The parameter will remain fixed at this value during the optimization process, and will not be updated. This method does not affect model evaluation.

Parameters:
valuefloat or array_like

Value at which to freeze the parameter during optimization. This value must be within the lower and upper bounds of the parameter.

Parameter.set(**attributes)[source]

Set one or multiple attributes for a parameter. See list of attributes for a reference list.

This method allows users to set the value of one or more attributes for a Parameter object. The list of attributes that can be set are the same as the attributes of the Parameter class, namely: name, description, unit, par0, lb, ub, linear, frozen, and value.

Parameters:
attributeskeyword/values pairs

Pairs of keywords defining the parameter attribute and the value to be assigned.

Examples

Setting a parameter’s start value

parameter.set(par0=0.5)

Setting both the lower bound and upper bound values

parameter.set(lb=0, ub=1)
Parameter.setas(parameter)[source]

Copy all attributes from an input parameter to the current parameter.

This method allows the user to copy all attributes from an input parameter object to the current parameter object. This can be useful when initializing multiple parameters with the same values.

Parameters:
parameterParameter object

Model parameters from which to extract the attributes.

Parameter.unfreeze()[source]

Release a frozen parameter’s value during a fit/optimization.

This method allows the user to release a previously frozen parameter during optimization. The parameter will no longer be fixed at a specific value and will be updated according to the optimization algorithm. This method does not affect model evaluation.

Inherited Methods