13 #ifndef MLPACK_CORE_DISTRIBUTIONS_LAPLACE_DISTRIBUTION_HPP 14 #define MLPACK_CORE_DISTRIBUTIONS_LAPLACE_DISTRIBUTION_HPP 17 namespace distribution {
66 mean(arma::zeros<arma::vec>(dimensionality)), scale(scale) { }
75 mean(mean), scale(scale) { }
101 arma::vec result(
mean.n_elem);
107 for (
size_t i = 0; i < result.n_elem; ++i)
110 result[i] =
mean[i] +
scale * std::log(1 + 2.0 * (result[i] - 0.5));
112 result[i] =
mean[i] -
scale * std::log(1 - 2.0 * (result[i] - 0.5));
123 void Estimate(
const arma::mat& observations);
130 void Estimate(
const arma::mat& observations,
131 const arma::vec& probabilities);
146 template<
typename Archive>
void Estimate(const arma::mat &observations)
Estimate the Laplace distribution directly from the given observations.
arma::vec Random() const
Return a randomly generated observation according to the probability distribution defined by this obj...
Linear algebra utility functions, generally performed on matrices or vectors.
The multivariate Laplace distribution centered at 0 has pdf.
FirstShim< T > CreateNVP(T &t, const std::string &name, typename std::enable_if_t< HasSerialize< T >::value > *=0)
Call this function to produce a name-value pair; this is similar to BOOST_SERIALIZATION_NVP(), but should be used for types that have a Serialize() function (or contain a type that has a Serialize() function) instead of a serialize() function.
double scale
Scale parameter of the distribution.
LaplaceDistribution(const size_t dimensionality, const double scale)
Construct the Laplace distribution with the given scale and dimensionality.
double Probability(const arma::vec &observation) const
Return the probability of the given observation.
double LogProbability(const arma::vec &observation) const
Return the log probability of the given observation.
LaplaceDistribution()
Default constructor, which creates a Laplace distribution with zero dimension and zero scale paramete...
void Serialize(Archive &ar, const unsigned int)
Serialize the distribution.
const arma::vec & Mean() const
Return the mean.
LaplaceDistribution(const arma::vec &mean, const double scale)
Construct the Laplace distribution with the given mean and scale parameter.
double & Scale()
Modify the scale parameter.
size_t Dimensionality() const
Return the dimensionality of this distribution.
double Scale() const
Return the scale parameter.
arma::vec & Mean()
Modify the mean.
arma::vec mean
Mean of the distribution.