\section{Discrete\+Distribution Class Reference}
\label{classmlpack_1_1distribution_1_1DiscreteDistribution}\index{Discrete\+Distribution@{Discrete\+Distribution}}


A discrete distribution where the only observations are discrete observations.  


\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\textbf{ Discrete\+Distribution} ()
\begin{DoxyCompactList}\small\item\em Default constructor, which creates a distribution that has no observations. \end{DoxyCompactList}\item 
\textbf{ Discrete\+Distribution} (const size\+\_\+t num\+Observations)
\begin{DoxyCompactList}\small\item\em Define the discrete distribution as having num\+Observations possible observations. \end{DoxyCompactList}\item 
\textbf{ Discrete\+Distribution} (const arma\+::\+Col$<$ size\+\_\+t $>$ \&num\+Observations)
\begin{DoxyCompactList}\small\item\em Define the multidimensional discrete distribution as having num\+Observations possible observations. \end{DoxyCompactList}\item 
\textbf{ Discrete\+Distribution} (const std\+::vector$<$ arma\+::vec $>$ \&probabilities)
\begin{DoxyCompactList}\small\item\em Define the multidimensional discrete distribution as having the given probabilities for each observation. \end{DoxyCompactList}\item 
size\+\_\+t \textbf{ Dimensionality} () const
\begin{DoxyCompactList}\small\item\em Get the dimensionality of the distribution. \end{DoxyCompactList}\item 
double \textbf{ Log\+Probability} (const arma\+::vec \&observation) const
\begin{DoxyCompactList}\small\item\em Return the log probability of the given observation. \end{DoxyCompactList}\item 
void \textbf{ Log\+Probability} (const arma\+::mat \&x, arma\+::vec \&log\+Probabilities) const
\begin{DoxyCompactList}\small\item\em Returns the \doxyref{Log}{p.}{classmlpack_1_1Log} probability of the given matrix. \end{DoxyCompactList}\item 
arma\+::vec \& \textbf{ Probabilities} (const size\+\_\+t dim=0)
\begin{DoxyCompactList}\small\item\em Return the vector of probabilities for the given dimension. \end{DoxyCompactList}\item 
const arma\+::vec \& \textbf{ Probabilities} (const size\+\_\+t dim=0) const
\begin{DoxyCompactList}\small\item\em Modify the vector of probabilities for the given dimension. \end{DoxyCompactList}\item 
double \textbf{ Probability} (const arma\+::vec \&observation) const
\begin{DoxyCompactList}\small\item\em Return the probability of the given observation. \end{DoxyCompactList}\item 
void \textbf{ Probability} (const arma\+::mat \&x, arma\+::vec \&probabilities) const
\begin{DoxyCompactList}\small\item\em Calculates the Discrete probability density function for each data point (column) in the given matrix. \end{DoxyCompactList}\item 
arma\+::vec \textbf{ Random} () const
\begin{DoxyCompactList}\small\item\em Return a randomly generated observation (one-\/dimensional vector; one observation) according to the probability distribution 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}\item 
void \textbf{ Train} (const arma\+::mat \&observations)
\begin{DoxyCompactList}\small\item\em Estimate the probability distribution directly from the given observations. \end{DoxyCompactList}\item 
void \textbf{ Train} (const arma\+::mat \&observations, const arma\+::vec \&probabilities)
\begin{DoxyCompactList}\small\item\em Estimate the probability distribution from the given observations, taking into account the probability of each observation actually being from this distribution. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
A discrete distribution where the only observations are discrete observations. 

This is useful (for example) with discrete Hidden Markov Models, where observations are non-\/negative integers representing specific emissions.

No bounds checking is performed for observations, so if an invalid observation is passed (i.\+e. observation $>$ num\+Observations), a crash will probably occur.

This distribution only supports one-\/dimensional observations, so when passing an arma\+::vec as an observation, it should only have one dimension (vec.\+n\+\_\+rows == 1). Any additional dimensions will simply be ignored.

\begin{DoxyNote}{Note}
This class, like every other class in mlpack, uses arma\+::vec to represent observations. While a discrete distribution only has positive integers (size\+\_\+t) as observations, these can be converted to doubles (which is what arma\+::vec holds). This distribution internally converts those doubles back into size\+\_\+t before comparisons. 
\end{DoxyNote}


Definition at line 45 of file discrete\+\_\+distribution.\+hpp.



\subsection{Constructor \& Destructor Documentation}
\mbox{\label{classmlpack_1_1distribution_1_1DiscreteDistribution_a354d0d2ba43923b6f81b1747809dace0}} 
\index{mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}!Discrete\+Distribution@{Discrete\+Distribution}}
\index{Discrete\+Distribution@{Discrete\+Distribution}!mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}}
\subsubsection{Discrete\+Distribution()\hspace{0.1cm}{\footnotesize\ttfamily [1/4]}}
{\footnotesize\ttfamily \textbf{ Discrete\+Distribution} (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Default constructor, which creates a distribution that has no observations. 



Definition at line 52 of file discrete\+\_\+distribution.\+hpp.

\mbox{\label{classmlpack_1_1distribution_1_1DiscreteDistribution_ae715f8fa95dfd6f96f94348dcd9bf5a6}} 
\index{mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}!Discrete\+Distribution@{Discrete\+Distribution}}
\index{Discrete\+Distribution@{Discrete\+Distribution}!mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}}
\subsubsection{Discrete\+Distribution()\hspace{0.1cm}{\footnotesize\ttfamily [2/4]}}
{\footnotesize\ttfamily \textbf{ Discrete\+Distribution} (\begin{DoxyParamCaption}\item[{const size\+\_\+t}]{num\+Observations }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Define the discrete distribution as having num\+Observations possible observations. 

The probability in each state will be set to (1 / num\+Observations).


\begin{DoxyParams}{Parameters}
{\em num\+Observations} & Number of possible observations this distribution can have. \\
\hline
\end{DoxyParams}


Definition at line 63 of file discrete\+\_\+distribution.\+hpp.

\mbox{\label{classmlpack_1_1distribution_1_1DiscreteDistribution_ad61f6ecc3bc550bdff56da47871813b5}} 
\index{mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}!Discrete\+Distribution@{Discrete\+Distribution}}
\index{Discrete\+Distribution@{Discrete\+Distribution}!mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}}
\subsubsection{Discrete\+Distribution()\hspace{0.1cm}{\footnotesize\ttfamily [3/4]}}
{\footnotesize\ttfamily \textbf{ Discrete\+Distribution} (\begin{DoxyParamCaption}\item[{const arma\+::\+Col$<$ size\+\_\+t $>$ \&}]{num\+Observations }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Define the multidimensional discrete distribution as having num\+Observations possible observations. 

The probability in each state will be set to (1 / num\+Observations of each dimension).


\begin{DoxyParams}{Parameters}
{\em num\+Observations} & Number of possible observations this distribution can have. \\
\hline
\end{DoxyParams}


Definition at line 76 of file discrete\+\_\+distribution.\+hpp.

\mbox{\label{classmlpack_1_1distribution_1_1DiscreteDistribution_ac11a63ab01caa525fede366a32f0371d}} 
\index{mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}!Discrete\+Distribution@{Discrete\+Distribution}}
\index{Discrete\+Distribution@{Discrete\+Distribution}!mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}}
\subsubsection{Discrete\+Distribution()\hspace{0.1cm}{\footnotesize\ttfamily [4/4]}}
{\footnotesize\ttfamily \textbf{ Discrete\+Distribution} (\begin{DoxyParamCaption}\item[{const std\+::vector$<$ arma\+::vec $>$ \&}]{probabilities }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Define the multidimensional discrete distribution as having the given probabilities for each observation. 


\begin{DoxyParams}{Parameters}
{\em probabilities} & Probabilities of each possible observation. \\
\hline
\end{DoxyParams}


Definition at line 98 of file discrete\+\_\+distribution.\+hpp.



\subsection{Member Function Documentation}
\mbox{\label{classmlpack_1_1distribution_1_1DiscreteDistribution_a78eda6bfb9e9462afa0fc85e32abe1af}} 
\index{mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}!Dimensionality@{Dimensionality}}
\index{Dimensionality@{Dimensionality}!mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}}
\subsubsection{Dimensionality()}
{\footnotesize\ttfamily size\+\_\+t Dimensionality (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Get the dimensionality of the distribution. 



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

\mbox{\label{classmlpack_1_1distribution_1_1DiscreteDistribution_a7063c1fb92f512f32bf44542c7528739}} 
\index{mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}!Log\+Probability@{Log\+Probability}}
\index{Log\+Probability@{Log\+Probability}!mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}}
\subsubsection{Log\+Probability()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily double Log\+Probability (\begin{DoxyParamCaption}\item[{const arma\+::vec \&}]{observation }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return the log probability of the given observation. 

If the observation is greater than the number of possible observations, then a crash will probably occur -- bounds checking is not performed.


\begin{DoxyParams}{Parameters}
{\em observation} & Observation to return the log probability of. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\doxyref{Log}{p.}{classmlpack_1_1Log} probability of the given observation. 
\end{DoxyReturn}


Definition at line 166 of file discrete\+\_\+distribution.\+hpp.



References Discrete\+Distribution\+::\+Probability().

\mbox{\label{classmlpack_1_1distribution_1_1DiscreteDistribution_aabd4dbf56bd3d719aede447516d68296}} 
\index{mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}!Log\+Probability@{Log\+Probability}}
\index{Log\+Probability@{Log\+Probability}!mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}}
\subsubsection{Log\+Probability()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily void Log\+Probability (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{x,  }\item[{arma\+::vec \&}]{log\+Probabilities }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Returns the \doxyref{Log}{p.}{classmlpack_1_1Log} probability of the given matrix. 

These values are stored in log\+Probabilities.


\begin{DoxyParams}{Parameters}
{\em x} & List of observations. \\
\hline
{\em log\+Probabilities} & Output log-\/probabilities for each input observation. \\
\hline
\end{DoxyParams}


Definition at line 194 of file discrete\+\_\+distribution.\+hpp.



References Discrete\+Distribution\+::\+Probability(), Discrete\+Distribution\+::\+Random(), and Discrete\+Distribution\+::\+Train().

\mbox{\label{classmlpack_1_1distribution_1_1DiscreteDistribution_a5345d11b5eb6c28dbf0f252e1110909b}} 
\index{mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}!Probabilities@{Probabilities}}
\index{Probabilities@{Probabilities}!mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}}
\subsubsection{Probabilities()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily arma\+::vec\& Probabilities (\begin{DoxyParamCaption}\item[{const size\+\_\+t}]{dim = {\ttfamily 0} }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Return the vector of probabilities for the given dimension. 



Definition at line 232 of file discrete\+\_\+distribution.\+hpp.

\mbox{\label{classmlpack_1_1distribution_1_1DiscreteDistribution_a5742ca9717cead69c579e7a1af5f487d}} 
\index{mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}!Probabilities@{Probabilities}}
\index{Probabilities@{Probabilities}!mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}}
\subsubsection{Probabilities()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily const arma\+::vec\& Probabilities (\begin{DoxyParamCaption}\item[{const size\+\_\+t}]{dim = {\ttfamily 0} }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Modify the vector of probabilities for the given dimension. 



Definition at line 234 of file discrete\+\_\+distribution.\+hpp.

\mbox{\label{classmlpack_1_1distribution_1_1DiscreteDistribution_ab72935d592516e77511d0b5e703c0d41}} 
\index{mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}!Probability@{Probability}}
\index{Probability@{Probability}!mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}}
\subsubsection{Probability()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily double Probability (\begin{DoxyParamCaption}\item[{const arma\+::vec \&}]{observation }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return the probability of the given observation. 

If the observation is greater than the number of possible observations, then a crash will probably occur -- bounds checking is not performed.


\begin{DoxyParams}{Parameters}
{\em observation} & Observation to return the probability of. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Probability of the given observation. 
\end{DoxyReturn}


Definition at line 127 of file discrete\+\_\+distribution.\+hpp.



References Log\+::\+Fatal.



Referenced by Discrete\+Distribution\+::\+Log\+Probability(), and Discrete\+Distribution\+::\+Probability().

\mbox{\label{classmlpack_1_1distribution_1_1DiscreteDistribution_a1e516aca34e9c99caf1431a822d87fc6}} 
\index{mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}!Probability@{Probability}}
\index{Probability@{Probability}!mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}}
\subsubsection{Probability()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily void Probability (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{x,  }\item[{arma\+::vec \&}]{probabilities }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Calculates the Discrete probability density function for each data point (column) in the given matrix. 


\begin{DoxyParams}{Parameters}
{\em x} & List of observations. \\
\hline
{\em probabilities} & Output probabilities for each input observation. \\
\hline
\end{DoxyParams}


Definition at line 179 of file discrete\+\_\+distribution.\+hpp.



References Discrete\+Distribution\+::\+Probability().

\mbox{\label{classmlpack_1_1distribution_1_1DiscreteDistribution_a2c6f8d5bb4eacf7de767d2172b320756}} 
\index{mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}!Random@{Random}}
\index{Random@{Random}!mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}}
\subsubsection{Random()}
{\footnotesize\ttfamily arma\+::vec Random (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const}



Return a randomly generated observation (one-\/dimensional vector; one observation) according to the probability distribution defined by this object. 

\begin{DoxyReturn}{Returns}
Random observation. 
\end{DoxyReturn}


Referenced by Discrete\+Distribution\+::\+Log\+Probability(), Mock\+Categorical\+Data(), and Aggregated\+Policy$<$ Policy\+Type $>$\+::\+Sample().

\mbox{\label{classmlpack_1_1distribution_1_1DiscreteDistribution_af0dd9205158ccf7bcfcd8ff81f79c927}} 
\index{mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}!serialize@{serialize}}
\index{serialize@{serialize}!mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+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 241 of file discrete\+\_\+distribution.\+hpp.

\mbox{\label{classmlpack_1_1distribution_1_1DiscreteDistribution_a269c6f8a40ce41a5f7b6d035aef58238}} 
\index{mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}!Train@{Train}}
\index{Train@{Train}!mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}}
\subsubsection{Train()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily void Train (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{observations }\end{DoxyParamCaption})}



Estimate the probability distribution directly from the given observations. 

If any of the observations is greater than num\+Observations, a crash is likely to occur.


\begin{DoxyParams}{Parameters}
{\em observations} & List of observations. \\
\hline
\end{DoxyParams}


Referenced by Discrete\+Distribution\+::\+Log\+Probability().

\mbox{\label{classmlpack_1_1distribution_1_1DiscreteDistribution_ad71152f8853ac60c92a165ed72384125}} 
\index{mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}!Train@{Train}}
\index{Train@{Train}!mlpack\+::distribution\+::\+Discrete\+Distribution@{mlpack\+::distribution\+::\+Discrete\+Distribution}}
\subsubsection{Train()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily void Train (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{observations,  }\item[{const arma\+::vec \&}]{probabilities }\end{DoxyParamCaption})}



Estimate the probability distribution from the given observations, taking into account the probability of each observation actually being from this distribution. 


\begin{DoxyParams}{Parameters}
{\em observations} & List of observations. \\
\hline
{\em probabilities} & List of probabilities that each observation is actually from this distribution. \\
\hline
\end{DoxyParams}


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