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);
134 const arma::vec&
Mean()
const {
return mean; }
136 arma::vec&
Mean() {
return mean; }
139 double Scale()
const {
return scale; }
146 template<
typename Archive>
void Serialize(Archive &ar, const unsigned int)
Serialize the distribution.
LaplaceDistribution(const arma::vec &mean, const double scale)
Construct the Laplace distribution with the given mean and scale parameter.
FirstShim< T > CreateNVP(T &t, const std::string &name, typename boost::enable_if< HasSerialize< T >>::type *=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.
The multivariate Laplace distribution centered at 0 has pdf.
LaplaceDistribution()
Default constructor, which creates a Laplace distribution with zero dimension and zero scale paramete...
arma::vec Random() const
Return a randomly generated observation according to the probability distribution defined by this obj...
double LogProbability(const arma::vec &observation) const
Return the log probability of the given observation.
double Probability(const arma::vec &observation) const
Return the probability of the given observation.
const arma::vec & Mean() const
Return the mean.
void Estimate(const arma::mat &observations)
Estimate the Laplace distribution directly from the given observations.
size_t Dimensionality() const
Return the dimensionality of this distribution.
double & Scale()
Modify the scale parameter.
LaplaceDistribution(const size_t dimensionality, const double scale)
Construct the Laplace distribution with the given scale and dimensionality.
double Scale() const
Return the scale parameter.
arma::vec & Mean()
Modify the mean.