Var.new_obs()#
- classmethod Var.new_obs(value, dist=None, name='', distribution=None, convert='default')[source]#
Initializes a strong variable that holds observed data.
An observed variables is a strong variable that can have a distribution. If it does have a distribution, its
log_probis counted in a model’s log likelihood, i.e.log_lik.- 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 aModel.convert (
Callable[[Any],Any] |Literal['default'], default:'default') – A function used to process the value of this variable. The default uses the function stored inconvert_value, which isjax.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 namedist.
See also
Var.new_paramInitializes a strong variable that acts as a model parameter.
Var.new_calcInitializes a weak variable that is a function of other variables.
Var.new_valueInitializes a strong variable without a distribution.
- Return type:
Examples
A simple observed variable without a distribution and without a name:
>>> x = lsl.Var.new_obs(1.0) >>> x Var(name="")
A simple observed variable with a normal distribution:
>>> prior = lsl.Dist(tfd.Normal, loc=0.0, scale=1.0) >>> x = lsl.Var.new_param(1.0, dist=prior) >>> x Var(name="")