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(cost, grad_vars, extra_vars=None, dtype=None, casting='no', **kwargs)

Create a theano function that computes a value and its gradient.

Parameters
costtheano variable

The value that we compute with its gradient.

grad_varslist of named theano variables or None

The arguments with respect to which the gradient is computed.

extra_varslist 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.

dtypestr, 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.

kwargs

Extra arguments are passed on to theano.function.

Attributes
sizeint

The number of elements in the parameter array.

profiletheano profiling object or None

Profiling information of the underlying theano function.

array_to_dict(self, array)

Convert an array to a dictionary containing the grad_vars.

array_to_full_dict(self, array)

Convert an array to a dictionary with grad_vars and extra_vars.

dict_to_array(self, 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
typetheano type (optional)
ownertheano owner (optional)
namestr
distributionDistribution
modelModel
total_sizescalar 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
typetheano type (optional)
ownertheano owner (optional)
namestr
distributionDistribution
modelModel
total_sizescalar 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
typetheano type (optional)
ownertheano owner (optional)
namestr
distributionDistribution
modelModel
total_sizescalar 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
typetheano type (optional)
ownertheano owner (optional)
namestr
distributionDistribution
modelModel
total_sizescalar Tensor (optional)

needed for upscaling logp

property init_value

Convenience attribute to return tag.test_value