mxfusion.components.distributions.normal

Members

class mxfusion.components.distributions.normal.Normal(mean, variance, rand_gen=None, dtype=None, ctx=None)

Bases: mxfusion.components.distributions.univariate.UnivariateDistribution

The one-dimensional normal distribution. The normal distribution can be defined over a scalar random variable or an array of random variables. In case of an array of random variables, the mean and variance are broadcasted to the shape of the output random variable (array).

Parameters:
  • mean (Variable) – Mean of the normal distribution.
  • variance (Variable) – Variance of the normal 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).
log_pdf_impl(mean, variance, random_variable, F=None)

Computes the logarithm of the probability density function (PDF) of the normal distribution.

Parameters:
  • mean (MXNet NDArray or MXNet Symbol) – the mean of the normal distribution.
  • variance (MXNet NDArray or MXNet Symbol) – the variance of the normal distributions.
  • random_variable (MXNet NDArray or MXNet Symbol) – the random variable of the normal distribution.
  • F – the MXNet computation mode (mxnet.symbol or mxnet.ndarray).
Returns:

log pdf of the distribution.

Rtypes:

MXNet NDArray or MXNet Symbol

draw_samples_impl(mean, variance, rv_shape, num_samples=1, F=None)

Draw samples from the normal distribution.

Parameters:
  • mean (MXNet NDArray or MXNet Symbol) – the mean of the normal distribution.
  • variance (MXNet NDArray or MXNet Symbol) – the variance of the normal distributions.
  • rv_shape (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 normal distribution.

Rtypes:

MXNet NDArray or MXNet Symbol

static define_variable(mean=0.0, variance=1.0, shape=None, rand_gen=None, dtype=None, ctx=None)

Creates and returns a random variable drawn from a normal distribution.

Parameters:
  • mean – Mean of the distribution.
  • variance – Variance of the distribution.
  • 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).
Returns:

the random variables drawn from the normal distribution.

Rtypes:

Variable

class mxfusion.components.distributions.normal.MultivariateNormal(mean, covariance, rand_gen=None, minibatch_ratio=1.0, dtype=None, ctx=None)

Bases: mxfusion.components.distributions.distribution.Distribution

The multi-dimensional normal distribution.

Parameters:
  • mean (Variable) – Mean of the normal distribution.
  • covariance (Variable) – Covariance matrix of 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)

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 (a dict of {'name' : Variable} or None) – new input variables of the factor.
  • outputs (a dict of {'name' : Variable} or None) – new output variables of the factor.
log_pdf_impl(mean, covariance, random_variable, F=None)

Computes the logarithm of the probability density function (PDF) of the normal distribution.

Parameters:
  • mean (MXNet NDArray or MXNet Symbol) – the mean of the normal distribution.
  • covariance (MXNet NDArray or MXNet Symbol) – the covariance of the distribution.
  • random_variable (MXNet NDArray or MXNet Symbol) – the random variable of the normal distribution.
  • F – the MXNet computation mode (mxnet.symbol or mxnet.ndarray).
Returns:

log pdf of the distribution.

Rtypes:

MXNet NDArray or MXNet Symbol

draw_samples_impl(mean, covariance, rv_shape, num_samples=1, F=None)

Draw a number of samples from the normal distribution.

Parameters:
  • mean (MXNet NDArray or MXNet Symbol) – the mean of the normal distribution.
  • covariance (MXNet NDArray or MXNet Symbol) – the covariance of the normal distributions.
  • rv_shape (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 normal distribution

Rtypes:

MXNet NDArray or MXNet Symbol

static define_variable(shape, mean=0.0, covariance=None, rand_gen=None, minibatch_ratio=1.0, dtype=None, ctx=None)

Creates and returns a random variable drawn from a normal distribution.

Parameters:
  • mean – Mean of the distribution.
  • covariance – Variance of the distribution.
  • 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).
Returns:

the random variables drawn from the normal distribution.

Rtypes:

Variable

class mxfusion.components.distributions.normal.NormalMeanPrecision(mean, precision, rand_gen=None, dtype=None, ctx=None)

Bases: mxfusion.components.distributions.univariate.UnivariateDistribution

The one-dimensional normal distribution, parameterized by mean and precision rather than mean and variance. The normal distribution can be defined over a scalar random variable or an array of random variables. In case of an array of random variables, the mean and precisions are broadcasted to the shape of the output random variable (array).

Parameters:
  • mean (Variable) – Mean of the normal distribution.
  • precision (Variable) – Precision of the normal 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).
log_pdf_impl(mean, precision, random_variable, F=None)

Computes the logarithm of the probability density function (PDF) of the normal distribution.

Parameters:
  • mean (MXNet NDArray or MXNet Symbol) – the mean of the normal distribution.
  • precision (MXNet NDArray or MXNet Symbol) – the precision of the normal distributions.
  • random_variable (MXNet NDArray or MXNet Symbol) – the random variable of the normal distribution.
  • F – the MXNet computation mode (mxnet.symbol or mxnet.ndarray).
Returns:

log pdf of the distribution.

Rtypes:

MXNet NDArray or MXNet Symbol

draw_samples_impl(mean, precision, rv_shape, num_samples=1, F=None)

Draw samples from the normal distribution.

Parameters:
  • mean (MXNet NDArray or MXNet Symbol) – the mean of the normal distribution.
  • precision (MXNet NDArray or MXNet Symbol) – the precision of the normal distributions.
  • rv_shape (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 normal distribution.

Rtypes:

MXNet NDArray or MXNet Symbol

static define_variable(mean=0.0, precision=1.0, shape=None, rand_gen=None, dtype=None, ctx=None)

Creates and returns a random variable drawn from a normal distribution.

Parameters:
  • mean – Mean of the distribution.
  • precision – Precision of the distribution.
  • 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).
Returns:

the random variables drawn from the normal distribution.

Rtypes:

Variable

class mxfusion.components.distributions.normal.MultivariateNormalMeanPrecision(mean, precision, rand_gen=None, minibatch_ratio=1.0, dtype=None, ctx=None)

Bases: mxfusion.components.distributions.distribution.Distribution

The multi-dimensional normal distribution parameterized by mean and precision rather than mean and variance.

Parameters:
  • mean (Variable) – Mean of the normal distribution.
  • precision (Variable) – Precision matrix of 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)

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 (a dict of {'name' : Variable} or None) – new input variables of the factor.
  • outputs (a dict of {'name' : Variable} or None) – new output variables of the factor.
log_pdf_impl(mean, precision, random_variable, F=None)

Computes the logarithm of the probability density function (PDF) of the normal distribution.

Parameters:
  • mean (MXNet NDArray or MXNet Symbol) – the mean of the normal distribution.
  • precision (MXNet NDArray or MXNet Symbol) – the precision of the distribution.
  • random_variable (MXNet NDArray or MXNet Symbol) – the random variable of the normal distribution.
  • F – the MXNet computation mode (mxnet.symbol or mxnet.ndarray).
Returns:

log pdf of the distribution.

Rtypes:

MXNet NDArray or MXNet Symbol

draw_samples_impl(mean, precision, rv_shape, num_samples=1, F=None)

Draw a number of samples from the normal distribution.

Parameters:
  • mean (MXNet NDArray or MXNet Symbol) – the mean of the normal distribution.
  • precision (MXNet NDArray or MXNet Symbol) – the precision of the normal distributions.
  • rv_shape (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 normal distribution

Rtypes:

MXNet NDArray or MXNet Symbol

static define_variable(shape, mean=0.0, precision=None, rand_gen=None, minibatch_ratio=1.0, dtype=None, ctx=None)

Creates and returns a random variable drawn from a normal distribution.

Parameters:
  • mean – Mean of the distribution.
  • precision – Precision of the distribution.
  • 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).
Returns:

the random variables drawn from the normal distribution.

Rtypes:

Variable