27#ifndef expModGaussian_hpp
28#define expModGaussian_hpp
30#include <boost/math/tools/minima.hpp>
34#include "../constants.hpp"
53template <
typename realT>
60 return ( lambda / 2 ) * exp( ( lambda / 2 ) * ( 2 * mu + lambda * sigma * sigma - 2 * x ) ) *
61 std::erfc( ( mu + lambda * sigma * sigma - x ) / (
root_two<realT>() * sigma ) );
74template <
typename realT>
79 return mu + 1.0 / lambda;
92template <
typename realT>
97 return sigma * sigma + 1.0 / ( lambda * lambda );
100template <
typename realT>
107 realT operator()(
const realT &x )
123template <
typename realT>
132 std::cerr << mn <<
" " << sd <<
"\n";
134 emgModeFunc<realT> mf;
139 uintmax_t maxit = 1000;
142 std::pair<realT, realT> brack;
143 brack = boost::math::tools::brent_find_minima<emgModeFunc<realT>, realT>(
144 mf, mn - 2 * sd, mn + 2 * sd, std::numeric_limits<realT>::digits, maxit );
145 std::cerr << brack.first <<
" " << brack.second <<
" " << maxit <<
"\n";
151 std::cerr <<
"expModGaussianMode: No mode found\n";
152 return std::numeric_limits<realT>::quiet_NaN();
realT expModGaussianVariance(realT sigma, realT lambda)
The Variance of the Exponentially Modified Gaussian.
realT expModGaussian(realT x, realT mu, realT sigma, realT lambda)
The Exponentially Modified Gaussian at a point.
realT expModGaussianMode(realT mu, realT sigma, realT lambda)
The Mode of the Exponentially Modified Gaussian.
realT expModGaussianMean(realT mu, realT lambda)
The Mean of the Exponentially Modified Gaussian.
constexpr T root_two()
Get the value of sqrt(2).