Var.new_param()

Contents

Var.new_param()#

classmethod Var.new_param(value, dist=None, name='', inference=None, bijector=None, convert='default', distribution=None)[source]#

Initializes a strong variable that acts as a model parameter.

A parameter is a strong variable that can have a distribution. If it does have a distribution, its log_prob is counted in a model’s log prior, i.e. log_prior.

Parameters:
  • value (Any) – The value of the variable.

  • dist (Dist | None, default: None) – The probability distribution of the variable.

  • name (str, default: '') – The name of the variable. If you do not specify a name, a unique name will be automatically generated upon initialization of a Model.

  • inference (TypeAliasType, default: None) – Additional information that can be used to set up inference algorithms.

  • bijector (None | TypeAliasType | Literal['auto'], default: None) – Bijector for variable transformation. If "auto", uses the default event space bijector defined by the variable’s distribution. If None, no transformation takes place. If not None, the variable will call biject() with this bijector upon initialization. Any supplied inference information will be passed to the bijected variable.

  • convert (Callable[[Any], Any] | Literal['default'], default: 'default') – A function used to process the value of this variable. The default uses the function stored in convert_value, which is jax.numpy.asarray.

  • distribution (Dist | None, default: None) – Deprecated argument name for the probability distribution of the variable, kept for backwards-compatibility. Please use the new name dist.

See also

Var.new_obs

Initializes a strong variable that holds observed data.

Var.new_calc

Initializes a weak variable that is a function of other variables.

Var.new_value

Initializes a strong variable without a distribution.

Return type:

Var

Examples

A simple parameter without a distribution and without a name:

>>> x = lsl.Var.new_param(1.0)
>>> x
Var(name="")

A simple parameter with a normal prior:

>>> prior = lsl.Dist(tfd.Normal, loc=0.0, scale=1.0)
>>> x = lsl.Var.new_param(1.0, dist=prior)
>>> x
Var(name="")