\section{Bernoulli\+Distribution$<$ Data\+Type $>$ Class Template Reference}
\label{classmlpack_1_1ann_1_1BernoulliDistribution}\index{Bernoulli\+Distribution$<$ Data\+Type $>$@{Bernoulli\+Distribution$<$ Data\+Type $>$}}


Multiple independent Bernoulli distributions.  


\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\textbf{ Bernoulli\+Distribution} ()
\begin{DoxyCompactList}\small\item\em Default constructor, which creates a Bernoulli distribution with zero dimension. \end{DoxyCompactList}\item 
\textbf{ Bernoulli\+Distribution} (const Data\+Type \&param, const bool apply\+Logistic=true, const double eps=1e-\/10)
\begin{DoxyCompactList}\small\item\em Create multiple independent Bernoulli distributions whose p values are given by the param parameter. \end{DoxyCompactList}\item 
const Data\+Type \& \textbf{ Logits} () const
\begin{DoxyCompactList}\small\item\em Return the logits matrix. \end{DoxyCompactList}\item 
Data\+Type \& \textbf{ Logits} ()
\begin{DoxyCompactList}\small\item\em Return a modifiable copy of the pre probability matrix. \end{DoxyCompactList}\item 
double \textbf{ Log\+Probability} (const Data\+Type \&observation) const
\begin{DoxyCompactList}\small\item\em Return the log probabilities of the given matrix of observations. \end{DoxyCompactList}\item 
void \textbf{ Log\+Prob\+Backward} (const Data\+Type \&observation, Data\+Type \&output) const
\begin{DoxyCompactList}\small\item\em Stores the gradient of the log probabilities of the observations in the output matrix. \end{DoxyCompactList}\item 
double \textbf{ Probability} (const Data\+Type \&observation) const
\begin{DoxyCompactList}\small\item\em Return the probabilities of the given matrix of observations. \end{DoxyCompactList}\item 
const Data\+Type \& \textbf{ Probability} () const
\begin{DoxyCompactList}\small\item\em Return the probability matrix. \end{DoxyCompactList}\item 
Data\+Type \& \textbf{ Probability} ()
\begin{DoxyCompactList}\small\item\em Return a modifiable copy of the probability matrix. \end{DoxyCompactList}\item 
Data\+Type \textbf{ Sample} () const
\begin{DoxyCompactList}\small\item\em Return a matrix of randomly generated samples according to the probability distributions defined by this object. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Archive $>$ }\\void \textbf{ serialize} (Archive \&ar, const unsigned int)
\begin{DoxyCompactList}\small\item\em Serialize the distribution. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
\subsubsection*{template$<$typename Data\+Type = arma\+::mat$>$\newline
class mlpack\+::ann\+::\+Bernoulli\+Distribution$<$ Data\+Type $>$}

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.


\begin{DoxyTemplParams}{Template Parameters}
{\em Data\+Type} & Type of the input data. (arma\+::colvec, arma\+::mat, arma\+::sp\+\_\+mat or arma\+::cube). \\
\hline
\end{DoxyTemplParams}


Definition at line 34 of file bernoulli\+\_\+distribution.\+hpp.



\subsection{Constructor \& Destructor Documentation}
\mbox{\label{classmlpack_1_1ann_1_1BernoulliDistribution_a88d6abf9fc36d7f6975a64a14a6c03a6}} 
\index{mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}!Bernoulli\+Distribution@{Bernoulli\+Distribution}}
\index{Bernoulli\+Distribution@{Bernoulli\+Distribution}!mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}}
\subsubsection{Bernoulli\+Distribution()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily \textbf{ Bernoulli\+Distribution} (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



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

\mbox{\label{classmlpack_1_1ann_1_1BernoulliDistribution_a81bf5f2daf02b0a98d86ea65f24bc69b}} 
\index{mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}!Bernoulli\+Distribution@{Bernoulli\+Distribution}}
\index{Bernoulli\+Distribution@{Bernoulli\+Distribution}!mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}}
\subsubsection{Bernoulli\+Distribution()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily \textbf{ Bernoulli\+Distribution} (\begin{DoxyParamCaption}\item[{const Data\+Type \&}]{param,  }\item[{const bool}]{apply\+Logistic = {\ttfamily true},  }\item[{const double}]{eps = {\ttfamily 1e-\/10} }\end{DoxyParamCaption})}



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

Thus, we create nof\+Rows $\ast$ nof\+Columns 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 A\+NN module to define distribution for each feature in each batch, where number of features becomes nof\+Rows and batch size becomes nof\+Columns.

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


\begin{DoxyParams}{Parameters}
{\em param} & The matrix of probabilities or pre probabilities of the multiple distributions. \\
\hline
{\em apply\+Logsitic} & If true, we apply Logistic function to the param matrix (pre probability) to get probability. \\
\hline
{\em eps} & The minimum value used for computing logarithms and denominators. \\
\hline
\end{DoxyParams}


\subsection{Member Function Documentation}
\mbox{\label{classmlpack_1_1ann_1_1BernoulliDistribution_aebb63750cdd19cf5cc2828471451f77d}} 
\index{mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}!Logits@{Logits}}
\index{Logits@{Logits}!mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}}
\subsubsection{Logits()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily const Data\+Type\& Logits (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return the logits matrix. 



Definition at line 108 of file bernoulli\+\_\+distribution.\+hpp.

\mbox{\label{classmlpack_1_1ann_1_1BernoulliDistribution_a693726db71ae8d6dea2993305b8296e4}} 
\index{mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}!Logits@{Logits}}
\index{Logits@{Logits}!mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}}
\subsubsection{Logits()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily Data\+Type\& Logits (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Return a modifiable copy of the pre probability matrix. 



Definition at line 111 of file bernoulli\+\_\+distribution.\+hpp.

\mbox{\label{classmlpack_1_1ann_1_1BernoulliDistribution_a1b59fa6b8ee989ff2d9b0a001309e792}} 
\index{mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}!Log\+Probability@{Log\+Probability}}
\index{Log\+Probability@{Log\+Probability}!mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}}
\subsubsection{Log\+Probability()}
{\footnotesize\ttfamily double Log\+Probability (\begin{DoxyParamCaption}\item[{const Data\+Type \&}]{observation }\end{DoxyParamCaption}) const}



Return the log probabilities of the given matrix of observations. 


\begin{DoxyParams}{Parameters}
{\em observation} & The observation matrix. \\
\hline
\end{DoxyParams}


Referenced by Bernoulli\+Distribution$<$ Data\+Type $>$\+::\+Probability().

\mbox{\label{classmlpack_1_1ann_1_1BernoulliDistribution_a73599ea85b4aa7a913286b6f62e40ccc}} 
\index{mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}!Log\+Prob\+Backward@{Log\+Prob\+Backward}}
\index{Log\+Prob\+Backward@{Log\+Prob\+Backward}!mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}}
\subsubsection{Log\+Prob\+Backward()}
{\footnotesize\ttfamily void Log\+Prob\+Backward (\begin{DoxyParamCaption}\item[{const Data\+Type \&}]{observation,  }\item[{Data\+Type \&}]{output }\end{DoxyParamCaption}) const}



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


\begin{DoxyParams}{Parameters}
{\em observation} & The observation matrix. \\
\hline
{\em output} & The output matrix where the gradients are stored. \\
\hline
\end{DoxyParams}


Referenced by Bernoulli\+Distribution$<$ Data\+Type $>$\+::\+Probability().

\mbox{\label{classmlpack_1_1ann_1_1BernoulliDistribution_a5d5f71a6aaf6e56c1b5cce0bee23103f}} 
\index{mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}!Probability@{Probability}}
\index{Probability@{Probability}!mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}}
\subsubsection{Probability()\hspace{0.1cm}{\footnotesize\ttfamily [1/3]}}
{\footnotesize\ttfamily double Probability (\begin{DoxyParamCaption}\item[{const Data\+Type \&}]{observation }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return the probabilities of the given matrix of observations. 


\begin{DoxyParams}{Parameters}
{\em observation} & The observation matrix. \\
\hline
\end{DoxyParams}


Definition at line 72 of file bernoulli\+\_\+distribution.\+hpp.



References Bernoulli\+Distribution$<$ Data\+Type $>$\+::\+Log\+Probability(), Bernoulli\+Distribution$<$ Data\+Type $>$\+::\+Log\+Prob\+Backward(), and Bernoulli\+Distribution$<$ Data\+Type $>$\+::\+Sample().

\mbox{\label{classmlpack_1_1ann_1_1BernoulliDistribution_aa9aa637b51801aaa39ae77be9b6d9280}} 
\index{mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}!Probability@{Probability}}
\index{Probability@{Probability}!mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}}
\subsubsection{Probability()\hspace{0.1cm}{\footnotesize\ttfamily [2/3]}}
{\footnotesize\ttfamily const Data\+Type\& Probability (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return the probability matrix. 



Definition at line 102 of file bernoulli\+\_\+distribution.\+hpp.

\mbox{\label{classmlpack_1_1ann_1_1BernoulliDistribution_a11883ea7fd2a81bdd492d58f1ae13ed6}} 
\index{mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}!Probability@{Probability}}
\index{Probability@{Probability}!mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}}
\subsubsection{Probability()\hspace{0.1cm}{\footnotesize\ttfamily [3/3]}}
{\footnotesize\ttfamily Data\+Type\& Probability (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Return a modifiable copy of the probability matrix. 



Definition at line 105 of file bernoulli\+\_\+distribution.\+hpp.

\mbox{\label{classmlpack_1_1ann_1_1BernoulliDistribution_a59b1e2962ad6370100f34906d6fddd76}} 
\index{mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}!Sample@{Sample}}
\index{Sample@{Sample}!mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}}
\subsubsection{Sample()}
{\footnotesize\ttfamily Data\+Type Sample (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const}



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

\begin{DoxyReturn}{Returns}
Matrix(integer) of random samples from the multiple Bernoulli distributions. 
\end{DoxyReturn}


Referenced by Bernoulli\+Distribution$<$ Data\+Type $>$\+::\+Probability().

\mbox{\label{classmlpack_1_1ann_1_1BernoulliDistribution_af0dd9205158ccf7bcfcd8ff81f79c927}} 
\index{mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}!serialize@{serialize}}
\index{serialize@{serialize}!mlpack\+::ann\+::\+Bernoulli\+Distribution@{mlpack\+::ann\+::\+Bernoulli\+Distribution}}
\subsubsection{serialize()}
{\footnotesize\ttfamily void serialize (\begin{DoxyParamCaption}\item[{Archive \&}]{ar,  }\item[{const unsigned}]{int }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Serialize the distribution. 



Definition at line 117 of file bernoulli\+\_\+distribution.\+hpp.



The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
/var/www/mlpack.\+ratml.\+org/mlpack.\+org/\+\_\+src/mlpack-\/3.\+3.\+1/src/mlpack/methods/ann/dists/\textbf{ bernoulli\+\_\+distribution.\+hpp}\end{DoxyCompactItemize}
