14 #ifndef MLPACK_CORE_DISTRIBUTIONS_LAPLACE_DISTRIBUTION_HPP 15 #define MLPACK_CORE_DISTRIBUTIONS_LAPLACE_DISTRIBUTION_HPP 18 namespace distribution {
67 mean(arma::zeros<arma::vec>(dimensionality)), scale(scale) { }
77 mean(mean), scale(scale) { }
98 void Probability(
const arma::mat& x, arma::vec& probabilities)
const;
115 logProbabilities.set_size(x.n_cols);
116 for (
size_t i = 0; i < x.n_cols; ++i)
130 arma::vec result(mean.n_elem);
136 for (
size_t i = 0; i < result.n_elem; ++i)
139 result[i] = mean[i] + scale * std::log(1 + 2.0 * (result[i] - 0.5));
141 result[i] = mean[i] - scale * std::log(1 - 2.0 * (result[i] - 0.5));
152 void Estimate(
const arma::mat& observations);
159 void Estimate(
const arma::mat& observations,
160 const arma::vec& probabilities);
163 const arma::vec&
Mean()
const {
return mean; }
165 arma::vec&
Mean() {
return mean; }
168 double Scale()
const {
return scale; }
175 template<
typename Archive>
178 ar(CEREAL_NVP(mean));
179 ar(CEREAL_NVP(scale));
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.
Linear algebra utility functions, generally performed on matrices or vectors.
The multivariate Laplace distribution centered at 0 has pdf.
LaplaceDistribution()
Default constructor, which creates a Laplace distribution with zero dimension and zero scale paramete...
size_t Dimensionality() const
Return the dimensionality of this distribution.
double LogProbability(const arma::vec &observation) const
Return the log probability of the given observation.
double Scale() const
Return the scale parameter.
void Estimate(const arma::mat &observations)
Estimate the Laplace distribution directly from the given observations.
double Probability(const arma::vec &observation) const
Return the probability of the given observation.
double & Scale()
Modify the scale parameter.
arma::vec Random() const
Return a randomly generated observation according to the probability distribution defined by this obj...
void serialize(Archive &ar, const uint32_t)
Serialize the distribution.
LaplaceDistribution(const size_t dimensionality, const double scale)
Construct the Laplace distribution with the given scale and dimensionality.
arma::vec & Mean()
Modify the mean.
void LogProbability(const arma::mat &x, arma::vec &logProbabilities) const
Evaluate log probability density function of given observation.