mxfusion.components.distributions.random_gen

Members

class mxfusion.components.distributions.random_gen.RandomGenerator

Bases: abc.ABC

The abstract class of the pseudo-random number generator.

static sample_normal(loc=0, scale=1, shape=None, dtype=None, out=None, ctx=None)
static sample_gamma(alpha=1, beta=1, shape=None, dtype=None, out=None, ctx=None)
static sample_multinomial(data, get_prob=True, dtype='int32', F=None)
static sample_bernoulli(prob_true=0.5, dtype='bool', F=None)
static sample_uniform(low=0.0, high=1.0, shape=None, dtype=None, out=None, ctx=None, F=None)
static sample_laplace(location=0.0, scale=1.0, shape=None, dtype=None, out=None, ctx=None, F=None)
class mxfusion.components.distributions.random_gen.MXNetRandomGenerator

Bases: mxfusion.components.distributions.random_gen.RandomGenerator

The MXNet pseudo-random number generator.

static sample_normal(loc=0, scale=1, shape=None, dtype=None, out=None, ctx=None, F=None)

Sample Normal distributed variables

Parameters:
  • loc – location (mean)
  • scale – scale (variance)
  • shape – Array shape of samples
  • dtype – Data type
  • out – Output variable
  • ctx – execution context
  • F – MXNet node
Returns:

Array of samples

static sample_multinomial(data, shape=None, get_prob=False, dtype='int32', F=None)

Sample Multinomial distributed variables

Parameters:data – An n dimensional array whose last dimension has length k, where

k is the number of possible outcomes of each multinomial distribution. For example, data with shape (m, n, k) specifies m*n multinomial distributions each with k possible outcomes. :param shape: Shape of the random variable :param get_prob: If true, a second array containing log likelihood of the drawn samples will also be returned. This is usually used for reinforcement learning, where you can provide reward as head gradient w.r.t. this array to estimate gradient. :param dtype: Data type :param F: MXNet node :return: Array of samples

static sample_bernoulli(prob_true=0.5, dtype=None, shape=None, F=None)

Sample Bernoulli distributed variables

Parameters:
  • shape – Array shape of samples
  • prob_true – Probability of being true
  • dtype – data type
  • F – MXNet node
Returns:

Array of samples

static sample_gamma(alpha=1, beta=1, shape=None, dtype=None, out=None, ctx=None, F=None)

Sample Gamma distributed variables

Parameters:
  • alpha – Also known as shape
  • beta – Also known as rate
  • shape – The number of samples to draw. If shape is, e.g., (m, n) and alpha and beta are scalars, output shape will be (m, n). If alpha and beta are NDArrays with shape, e.g., (x, y), then output will have shape (x, y, m, n), where m*n samples are drawn for each [alpha, beta) pair.
  • dtype – Data type
  • out – output variable
  • ctx – execution context
  • F – MXNet node
Returns:

Array of samples

static sample_uniform(low=0.0, high=1.0, shape=None, dtype=None, out=None, ctx=None, F=None)

Sample uniformly distributed variables Samples are uniformly distributed over the half-open interval [low, high) (includes low, but excludes high).

Parameters:
  • low – lower boundary of output interval
  • high – upper boundary of output interval
  • shape – Array shape of samples
  • dtype – Data type
  • out – output variable
  • ctx – execution context
  • F – MXNet node
Returns:

Array of samples

static sample_laplace(location=0.0, scale=1.0, shape=None, dtype=None, out=None, ctx=None, F=None)

Sample Laplace distributed variables

Parameters:
  • location – Location parameter (=mean)
  • scale – (>0) Also known as diversity
  • shape – Array shape of samples
  • dtype – Data type
  • out – output variable
  • ctx – execution context
  • F – MXNet node
Returns:

Array of samples