15 #ifndef __MLPACK_CORE_DISTRIBUTIONS_LAPLACE_DISTRIBUTION_HPP 16 #define __MLPACK_CORE_DISTRIBUTIONS_LAPLACE_DISTRIBUTION_HPP 19 namespace distribution {
68 mean(arma::zeros<arma::vec>(dimensionality)), scale(scale) { }
77 mean(mean), scale(scale) { }
103 arma::vec result(
mean.n_elem);
109 for (
size_t i = 0; i < result.n_elem; ++i)
112 result[i] =
mean[i] +
scale * std::log(1 + 2.0 * (result[i] - 0.5));
114 result[i] =
mean[i] -
scale * std::log(1 - 2.0 * (result[i] - 0.5));
125 void Estimate(
const arma::mat& observations);
132 void Estimate(
const arma::mat& observations,
133 const arma::vec& probabilities);
148 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.
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.
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.