Random Variables¶
The normal PyMC3 programmer will typically not need to interact with these classes, except possibly when debugging. Otherwise they are primarily of interest to developers.
-
class
pymc3.model.
PyMC3Variable
(type, owner=None, index=None, name=None)¶ Class to wrap Theano TensorVariable for custom behavior.
-
class
pymc3.model.
ValueGradFunction
(costs, grad_vars, extra_vars=None, *, dtype=None, casting='no', compute_grads=True, **kwargs)¶ Create a theano function that computes a value and its gradient.
- Parameters
- costs: list of theano variables
We compute the weighted sum of the specified theano values, and the gradient of that sum. The weights can be specified with ValueGradFunction.set_weights.
- grad_vars: list of named theano variables or None
The arguments with respect to which the gradient is computed.
- extra_vars: list of named theano variables or None
Other arguments of the function that are assumed constant. They are stored in shared variables and can be set using set_extra_values.
- dtype: str, default=theano.config.floatX
The dtype of the arrays.
- casting: {‘no’, ‘equiv’, ‘save’, ‘same_kind’, ‘unsafe’}, default=’no’
Casting rule for casting grad_args to the array dtype. See numpy.can_cast for a description of the options. Keep in mind that we cast the variables to the array and back from the array dtype to the variable dtype.
- compute_grads: bool, default=True
If False, return only the logp, not the gradient.
- kwargs
Extra arguments are passed on to theano.function.
- Attributes
- size: int
The number of elements in the parameter array.
- profile: theano profiling object or None
The profiling object of the theano function that computes value and gradient. This is None unless profile=True was set in the kwargs.
-
array_to_dict
(array)¶ Convert an array to a dictionary containing the grad_vars.
-
array_to_full_dict
(array)¶ Convert an array to a dictionary with grad_vars and extra_vars.
-
dict_to_array
(point)¶ Convert a dictionary with values for grad_vars to an array.
-
property
profile
¶ Profiling information of the underlying theano function.
-
class
pymc3.model.
FreeRV
(type=None, owner=None, index=None, name=None, distribution=None, total_size=None, model=None)¶ Unobserved random variable that a model is specified in terms of.
- Parameters
- type: theano type (optional)
- owner: theano owner (optional)
- name: str
- distribution: Distribution
- model: Model
- total_size: scalar Tensor (optional)
needed for upscaling logp
-
property
init_value
¶ Convenience attribute to return tag.test_value
-
class
pymc3.model.
ObservedRV
(type=None, owner=None, index=None, name=None, data=None, distribution=None, total_size=None, model=None)¶ Observed random variable that a model is specified in terms of. Potentially partially observed.
- Parameters
- type: theano type (optional)
- owner: theano owner (optional)
- name: str
- distribution: Distribution
- model: Model
- total_size: scalar Tensor (optional)
needed for upscaling logp
-
property
init_value
¶ Convenience attribute to return tag.test_value
-
class
pymc3.model.
MultiObservedRV
(name, data, distribution, total_size=None, model=None)¶ Observed random variable that a model is specified in terms of. Potentially partially observed.
- Parameters
- type: theano type (optional)
- owner: theano owner (optional)
- name: str
- distribution: Distribution
- model: Model
- total_size: scalar Tensor (optional)
needed for upscaling logp
-
class
pymc3.model.
TransformedRV
(type=None, owner=None, index=None, name=None, distribution=None, model=None, transform=None, total_size=None)¶ - Parameters
- type: theano type (optional)
- owner: theano owner (optional)
- name: str
- distribution: Distribution
- model: Model
- total_size: scalar Tensor (optional)
needed for upscaling logp
-
property
init_value
¶ Convenience attribute to return tag.test_value