elisa.models.parameter#

The parameter.

class AssignmentTracker[source]#

Bases: object

Track component assignment of a parameter.

Methods

append(cid, pname)

Append a new assignment record.

get_comp_param(comp_ids)

Get the earliest component assignment record within comp_ids.

remove(cid, pname)

Remove an assignment record.

append(cid: str, pname: str) None[source]#

Append a new assignment record.

remove(cid: str, pname: str) None[source]#

Remove an assignment record.

get_comp_param(comp_ids: Iterable[str]) tuple[str, str] | None[source]#

Get the earliest component assignment record within comp_ids.

class ParamInfo(name: str | Callable[[ParamIDStrMapping], str], latex: str | Callable[[ParamIDStrMapping], str], default: Any, bound: str, prior: str, log: bool, fixed: bool, tracker: AssignmentTracker, id_to_value: Callable[[ParamIDValMapping], JAXFloat], dist: Distribution | None = None, composite: bool = False, integrate: IntegralFactory | bool = False)[source]#

Bases: NamedTuple

Parameter information.

Methods

count(value, /)

Return number of occurrences of value.

index(value[, start, stop])

Return first index of value.

name: str | Callable[[dict[str, str]], str]#

Plain name of the parameter.

It is a getter function for composite parameter.

latex: str | Callable[[dict[str, str]], str]#

\(\LaTeX\) format of the parameter.

It is a getter function for composite parameter.

default: Any#

Default value of the parameter.

bound: str#

Value bound expression of the parameter.

prior: str#

Prior distribution expression of the parameter.

log: bool#

Whether the parameter is parameterized in a logarithmic scale.

fixed: bool#

Whether the parameter is fixed.

tracker: AssignmentTracker#

Component assignment tracker.

id_to_value: Callable[[dict[str, Array]], Array]#

Mapping function from id to value.

dist: Distribution | None#

NumPyro distribution for the parameter.

composite: bool#

Whether the parameter is composite.

integrate: Callable[[Callable[[Array, dict[str, Array]], Array]], Callable[[Array, dict[str, Array]], Array]] | bool#

Integration factory for the parameter for interval parameter.

For composite parameter composed by interval parameter, this is True.

class Parameter[source]#

Bases: ABC

Parameter base.

Attributes

default

Default value of the parameter.

fixed

Whether the parameter is fixed.

latex

\(\LaTeX\) format of the parameter.

log

Whether the parameter is parameterized in a logarithmic scale.

name

Plain name of the parameter.

abstract property name: str#

Plain name of the parameter.

abstract property latex: str#

\(\LaTeX\) format of the parameter.

abstract property default: Array#

Default value of the parameter.

abstract property log: bool#

Whether the parameter is parameterized in a logarithmic scale.

abstract property fixed: bool#

Whether the parameter is fixed.

class ParameterHelper(name: str, latex: str | None, default: Any | None = None)[source]#

Bases: Parameter

Handle name, latex, and default value of a parameter.

Attributes

default

Default value of the parameter.

fixed

Whether the parameter is fixed.

latex

\(\LaTeX\) format of the parameter.

log

Whether the parameter is parameterized in a logarithmic scale.

name

Plain name of the parameter.

property name: str#

Plain name of the parameter.

property latex: str#

\(\LaTeX\) format of the parameter.

abstract property default: Any#

Default value of the parameter.

class DistParameter(name: str, dist: Distribution, default: float, *, min: float | None = None, max: float | None = None, log: bool = False, fixed: bool = False, latex: str | None = None)[source]#

Bases: ParameterHelper

Define a parameter by a distribution.

Parameters:
  • name (str) – Parameter name.

  • dist (Distribution) – Numpyro distribution from which the parameter is sampled.

  • default (float) – Parameter default value.

  • min (float | None) – Parameter minimum value, for display purpose only. The default is None.

  • max (float | None) – Parameter maximum value, for display purpose only. The default is None.

  • log (bool) – Whether the parameter is parameterized in a logarithmic scale. The default is False.

  • fixed (bool) – Whether the parameter is fixed. The default is False.

  • latex (str | None) – \(\LaTeX\) format of the parameter. The default is as name.

Attributes

default

Default value of the parameter.

fixed

Whether the parameter is fixed.

latex

\(\LaTeX\) format of the parameter.

log

Whether the parameter is parameterized in a logarithmic scale.

name

Plain name of the parameter.

property default: Array#

Default value of the parameter.

property log: bool#

Whether the parameter is parameterized in a logarithmic scale.

property fixed: bool#

Whether the parameter is fixed.

class UniformParameter(name: str, default: float, min: float, max: float, *, log: bool = False, fixed: bool = False, latex: str | None = None)[source]#

Bases: DistParameter

Define the parameter by a uniform distribution.

Parameters:
  • name (str) – Parameter name.

  • default (float) – Parameter default value.

  • min (float) – Parameter minimum value.

  • max (float) – Parameter maximum value.

  • log (bool) – Whether the parameter is logarithmically uniform. The default is False.

  • fixed (bool) – Whether the parameter is fixed. The default is False.

  • latex (str | None) – \(\LaTeX\) format of the parameter. The default is as name.

Attributes

default

Default value of the parameter.

fixed

Whether the parameter is fixed.

latex

\(\LaTeX\) format of the parameter.

log

Whether the parameter is logarithmically uniform.

max

Parameter maximum value.

min

Parameter minimum value.

name

Plain name of the parameter.

property name: str#

Plain name of the parameter.

property latex: str#

\(\LaTeX\) format of the parameter.

property default: Array#

Default value of the parameter.

property min: Array#

Parameter minimum value.

property max: Array#

Parameter maximum value.

property log: bool#

Whether the parameter is logarithmically uniform.

property fixed: bool#

Whether the parameter is fixed.

class ConstantParameter(name: str, value: Any, latex: str | None = None)[source]#

Bases: ParameterHelper

Constant parameter.

Parameters:
  • name (str) – Parameter name.

  • value (Any) – The constant value of parameter.

  • latex (str | None) – \(\LaTeX\) format of the parameter. The default is as name.

Attributes

default

Default value of the parameter.

fixed

Constant parameter is fixed.

latex

\(\LaTeX\) format of the parameter.

log

Constant parameter is not logarithmically parameterized.

name

Plain name of the parameter.

property log: bool#

Constant parameter is not logarithmically parameterized.

property fixed: bool#

Constant parameter is fixed.

class ConstantValue(name: str, value: float, latex: str | None = None)[source]#

Bases: ConstantParameter

Parameter with a fixed value.

Parameters:
  • name (str) – str: Parameter name.

  • value (float) – float: Parameter value.

  • latex (str | None) – \(\LaTeX\) format of the parameter. The default is as name.

Attributes

default

Default value of the parameter.

fixed

Constant parameter is fixed.

latex

\(\LaTeX\) format of the parameter.

log

Constant parameter is not logarithmically parameterized.

name

Plain name of the parameter.

property default: Array#

Default value of the parameter.

class ConstantInterval(name: str, interval: Sequence[float], method: Literal['quadgk', 'quadcc', 'quadts', 'romberg', 'rombergts'] = 'quadgk', latex: str | None = None, **kwargs)[source]#

Bases: ConstantParameter

Constant parameter to be integrated over a given interval.

When assigning ConstantInterval parameters to a model component, the model will be evaluated according to the following formula:

\[\frac{1}{\prod_i (b_i - a_i)} \int f(E, \vec{\theta}(\vec{p}, \vec{q})) \, \mathrm{d} \vec{p}\]

where \(f\) is the model function, \(\vec{\theta}\) is the parameter vector of the model, \(\vec{p}\) is the ConstantInterval parameters, \(\vec{q}\) is the other parameters, and \(a_i\) and \(b_i\) are the intervals given by \(\vec{p}\).

Parameters:
  • name (str) – str: Parameter name.

  • interval (Sequence[float]) – array_like: The interval, a 2-element sequence.

  • method – Numerical integration method used to integrate over the parameter. Available options are:

Attributes

default

Default value of the parameter.

fixed

Constant parameter is fixed.

latex

\(\LaTeX\) format of the parameter.

log

Constant parameter is not logarithmically parameterized.

method

Numerical integration method.

name

Plain name of the parameter.

References

property default: Array#

Default value of the parameter.

property method: Literal['quadgk', 'quadcc', 'quadts', 'romberg', 'rombergts']#

Numerical integration method.

class CompositeParameter(params: Parameter | Sequence[Parameter], op: Callable[[...], Array], op_name: str, op_latex: str | None = None, *, op_symbol: Literal['+', '-', '*', '/', '^'] | None = None)[source]#

Bases: Parameter

Combine parameters to create a new parameter.

Parameters:
  • params (Parameter | Sequence[Parameter]) – Parameters to be combined.

  • op (Callable[..., Array]) – Function applied to params. The function should take the same number and order of arguments as params and return a single value. The function must be compatible with JAX.

  • op_name (str) – Name of the composition operator op.

  • op_latex (str | None) – \(\LaTeX\) format of the composition operator op. The default is as op_name.

Attributes

default

Default value of the parameter.

fixed

If the sub-parameters are all fixed.

latex

\(\LaTeX\) format of the parameter.

log

If the sub-parameters are all logarithmically parameterized.

name

Plain name of the parameter.

property name: str#

Plain name of the parameter.

property latex: str#

\(\LaTeX\) format of the parameter.

property default: Array#

Default value of the parameter.

property log: bool#

If the sub-parameters are all logarithmically parameterized.

property fixed: bool#

If the sub-parameters are all fixed.