13 #ifndef MLPACK_METHODS_ANN_DISTRIBUTIONS_NORMAL_DISTRIBUTION_IMPL_HPP 14 #define MLPACK_METHODS_ANN_DISTRIBUTIONS_NORMAL_DISTRIBUTION_IMPL_HPP 22 template<
typename DataType>
28 template<
typename DataType>
31 const DataType& sigma) :
38 template<
typename DataType>
41 return sigma * arma::randn<DataType>(mean.n_elem) + mean;
44 template<
typename DataType>
46 const DataType& observation)
const 48 const DataType v1 = arma::log(sigma) + std::log(std::sqrt(2 * M_PI));
49 const DataType v2 = arma::square(observation - mean) /
50 (2 * arma::square(sigma));
54 template<
typename DataType>
56 const DataType& observation,
58 DataType& dsigma)
const 60 dmu = (observation - mean) / (arma::square(sigma)) %
Probability(observation);
61 dsigma = (- 1.0 / sigma +
62 (arma::square(observation - mean) / arma::pow(sigma, 3)))
66 template<
typename DataType>
67 template<
typename Archive>
72 ar(CEREAL_NVP(sigma));
DataType Sample() const
Return a randomly generated observation according to the probability distribution defined by this obj...
Definition: normal_distribution_impl.hpp:39
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
DataType Probability(const DataType &observation) const
Return the probabilities of the given matrix of observations.
Definition: normal_distribution.hpp:54
void serialize(Archive &ar, const uint32_t)
Serialize the distribution.
Definition: normal_distribution_impl.hpp:68
NormalDistribution()
Default constructor, which creates a Normal distribution with zero dimension.
Definition: normal_distribution_impl.hpp:23
DataType LogProbability(const DataType &observation) const
Return the log probabilities of the given matrix of observations.
Definition: normal_distribution_impl.hpp:45
void ProbBackward(const DataType &observation, DataType &dmu, DataType &dsigma) const
Stores the gradient of the probabilities of the observations with respect to mean and standard deviat...
Definition: normal_distribution_impl.hpp:55