mxfusion.components.distributions.distribution

Members

class mxfusion.components.distributions.distribution.Distribution(inputs, outputs, input_names, output_names, rand_gen=None, dtype=None, ctx=None)

Bases: mxfusion.components.factor.Factor

The base class of a probability distribution associated with one or a set of random variables.

Parameters:
  • inputs ({name: Variable}) – the input variables that parameterize the probability distribution.
  • outputs ({name: Variable}) – the random variables drawn from the distribution.
  • rand_gen (RandomGenerator) – the random generator (default: MXNetRandomGenerator).
  • dtype (numpy.float32 or numpy.float64) – the data type for float point numbers.
  • ctx (None or mxnet.cpu or mxnet.gpu) – the mxnet context (default: None/current context).
replicate_self(attribute_map=None)

This functions is a copy constructor for the object. In order to perform copy construction we first call __new__() on the class which creates a blank object. We then initialize that object using the method’s standard init procedures, and do any extra copying of attributes.

Replicates this Factor, using new inputs, outputs, and a new uuid. Used during model replication to functionally replicate a factor into a new graph.

Parameters:
  • inputs (List of tuples of name to node e.g. [('random_variable': Variable y)] or None) – new input variables of the factor.
  • outputs (List of tuples of name to node e.g. [('random_variable': Variable y)] or None) – new output variables of the factor.
log_pdf(F, variables, targets=None)

Computes the logarithm of the probability density/mass function (PDF/PMF) of the distribution. The inputs and outputs variables are fetched from the variables argument according to their UUIDs.

Parameters:F – the MXNet computation mode (mxnet.symbol or mxnet.ndarray).
Returns:log pdf of the distribution
Rtypes:MXNet NDArray or MXNet Symbol
log_pdf_impl(F, **kwargs)

The implementation of log_pdf for a specific distribution.

Parameters:F – the MXNet computation mode (mxnet.symbol or mxnet.ndarray).
Returns:log pdf of the distribution
Rtypes:MXNet NDArray or MXNet Symbol
log_cdf(F=None, **kwargs)

Computes the logarithm of the cumulative distribution function (CDF) of the distribution.

Parameters:F – the MXNet computation mode (mxnet.symbol or mxnet.ndarray).
Returns:log cdf of the distribution.
Rtypes:MXNet NDArray or MXNet Symbol
draw_samples(F, variables, num_samples=1, targets=None, always_return_tuple=False)

Draw a number of samples from the distribution. All the dependent variables are automatically collected from a dictionary of variables according to the UUIDs of the dependent variables.

Parameters:
  • F – the MXNet computation mode (mxnet.symbol or mxnet.ndarray).
  • variables ({str(UUID): MXNet NDArray or Symbol}) – the set of variables where the dependent variables are collected from.
  • num_samples (int) – the number of drawn samples (default: one).
  • always_return_tuple – return the samples in a tuple of shape one. This allows easy programming when there

are potentially multiple output variables. :type always_return_tuple: boolean :returns: a set samples of the distribution. :rtypes: MXNet NDArray or MXNet Symbol or [MXNet NDArray or MXNet Symbol]

draw_samples_impl(rv_shape, num_samples=1, F=None, **kwargs)

The implementation of draw_samples for a specific distribution.

Parameters:
  • rv_shape (tuple, [tuple]) – the shape of each sample.
  • num_samples (int) – the number of drawn samples (default: one).
  • F – the MXNet computation mode (mxnet.symbol or mxnet.ndarray).
Returns:

a set samples of the distribution.

Rtypes:

MXNet NDArray or MXNet Symbol or [MXNet NDArray or MXNet Symbol]

static define_variable(shape=None, rand_gen=None, dtype=None, ctx=None, **kwargs)

Define a random variable that follows from the specified distribution.

Parameters:
  • shape (tuple or [tuple]) – the shape of the random variable(s).
  • rand_gen (RandomGenerator) – the random generator (default: MXNetRandomGenerator).
  • dtype (numpy.float32 or numpy.float64) – the data type for float point numbers.
  • ctx (None or mxnet.cpu or mxnet.gpu) – the mxnet context (default: None/current context).
  • kwargs – the input variables that parameterize the probability

distribution. :type kwargs: {name: Variable} :returns: the random variables drawn from the distribution. :rtypes: Variable or [Variable]