BernoulliDistribution< DataType > Class Template Reference

Multiple independent Bernoulli distributions. More...

## Public Member Functions

BernoulliDistribution ()
Default constructor, which creates a Bernoulli distribution with zero dimension. More...

BernoulliDistribution (const DataType ¶m, const bool applyLogistic=true, const double eps=1e-10)
Create multiple independent Bernoulli distributions whose p values are given by the param parameter. More...

const DataType & Logits () const
Return the logits matrix. More...

DataType & Logits ()
Return a modifiable copy of the pre probability matrix. More...

double LogProbability (const DataType &observation) const
Return the log probabilities of the given matrix of observations. More...

void LogProbBackward (const DataType &observation, DataType &output) const
Stores the gradient of the log probabilities of the observations in the output matrix. More...

double Probability (const DataType &observation) const
Return the probabilities of the given matrix of observations. More...

const DataType & Probability () const
Return the probability matrix. More...

DataType & Probability ()
Return a modifiable copy of the probability matrix. More...

DataType Sample () const
Return a matrix of randomly generated samples according to the probability distributions defined by this object. More...

template
void serialize (Archive &ar, const unsigned int)
Serialize the distribution. More...

## Detailed Description

### template class mlpack::ann::BernoulliDistribution< DataType >

Multiple independent Bernoulli distributions.

Bernoulli distribution is the discrete probability distribution of a random variable which takes the value 1 with probability p and the value 0 with probability q = 1 - p. In this implementation, the p values of the distributions are given by the param matrix.

Template Parameters
 DataType Type of the input data. (arma::colvec, arma::mat, arma::sp_mat or arma::cube).

Definition at line 34 of file bernoulli_distribution.hpp.

## ◆ BernoulliDistribution() [1/2]

 BernoulliDistribution ( )

Default constructor, which creates a Bernoulli distribution with zero dimension.

## ◆ BernoulliDistribution() [2/2]

 BernoulliDistribution ( const DataType & param, const bool applyLogistic = `true`, const double eps = `1e-10` )

Create multiple independent Bernoulli distributions whose p values are given by the param parameter.

Thus, we create nofRows * nofColumns distributions. The shape of the matrix of distributions is the same as the shape of the param matrix as each element of the param matrix parameterizes one Bernoulli distribution. This is used in the ANN module to define distribution for each feature in each batch, where number of features becomes nofRows and batch size becomes nofColumns.

applyLogistic has to be true if all the elements of param matrix are not in the range [0, 1].

Parameters
 param The matrix of probabilities or pre probabilities of the multiple distributions. applyLogistic If true, we apply Logistic function to the param matrix (pre probability) to get probability. eps The minimum value used for computing logarithms and denominators.

## ◆ Logits() [1/2]

 const DataType& Logits ( ) const
inline

Return the logits matrix.

Definition at line 108 of file bernoulli_distribution.hpp.

## ◆ Logits() [2/2]

 DataType& Logits ( )
inline

Return a modifiable copy of the pre probability matrix.

Definition at line 111 of file bernoulli_distribution.hpp.

## ◆ LogProbability()

 double LogProbability ( const DataType & observation ) const

Return the log probabilities of the given matrix of observations.

Parameters
 observation The observation matrix.

Referenced by BernoulliDistribution< DataType >::Probability().

## ◆ LogProbBackward()

 void LogProbBackward ( const DataType & observation, DataType & output ) const

Stores the gradient of the log probabilities of the observations in the output matrix.

Parameters
 observation The observation matrix. output The output matrix where the gradients are stored.

Referenced by BernoulliDistribution< DataType >::Probability().

## ◆ Probability() [1/3]

 double Probability ( const DataType & observation ) const
inline

Return the probabilities of the given matrix of observations.

Parameters
 observation The observation matrix.

Definition at line 72 of file bernoulli_distribution.hpp.

## ◆ Probability() [2/3]

 const DataType& Probability ( ) const
inline

Return the probability matrix.

Definition at line 102 of file bernoulli_distribution.hpp.

## ◆ Probability() [3/3]

 DataType& Probability ( )
inline

Return a modifiable copy of the probability matrix.

Definition at line 105 of file bernoulli_distribution.hpp.

## ◆ Sample()

 DataType Sample ( ) const

Return a matrix of randomly generated samples according to the probability distributions defined by this object.

Returns
Matrix(integer) of random samples from the multiple Bernoulli distributions.

Referenced by BernoulliDistribution< DataType >::Probability().

## ◆ serialize()

 void serialize ( Archive & ar, const unsigned int )
inline

Serialize the distribution.

Definition at line 117 of file bernoulli_distribution.hpp.

The documentation for this class was generated from the following file: