25#ifndef quantlib_gaussian_statistics_h
26#define quantlib_gaussian_statistics_h
133 Real m = this->mean();
134 Real std = this->standardDeviation();
138 Real firstTerm =
variance + m*m - 2.0*target*m + target*target;
139 Real alfa = gIntegral(target);
140 Real secondTerm = m - target;
142 Real result = alfa*firstTerm -
beta*secondTerm;
149 Real percentile)
const {
152 "percentile (" << percentile <<
") must be > 0.0");
154 "percentile (" << percentile <<
") must be < 1.0");
157 Stat::standardDeviation());
158 return gInverse(percentile);
164 Real percentile)
const {
166 return gaussianPercentile(1.0-percentile);
172 Real percentile)
const {
175 "percentile (" << percentile <<
") out of range [0.9, 1)");
177 Real result = gaussianPercentile(percentile);
179 return std::max<Real>(result, 0.0);
186 Real percentile)
const {
189 "percentile (" << percentile <<
") out of range [0.9, 1)");
191 Real result = gaussianPercentile(1.0-percentile);
195 return -std::min<Real>(result, 0.0);
202 Real percentile)
const {
204 "percentile (" << percentile <<
") out of range [0.9, 1)");
206 Real m = this->mean();
207 Real std = this->standardDeviation();
209 Real var = gInverse(1.0-percentile);
211 Real result = m -
std*
std*g(var)/(1.0-percentile);
215 return -std::min<Real>(result, 0.0);
223 this->standardDeviation());
224 return gIntegral(target);
231 Real m = this->mean();
232 Real std = this->standardDeviation();
235 return ( (target-m) +
std*
std*g(target)/gIntegral(target) );
Cumulative normal distribution function.
Statistics tool for gaussian-assumption risk measures.
Real gaussianAverageShortfall(Real target) const
gaussian-assumption Average Shortfall (averaged shortfallness)
Real gaussianDownsideVariance() const
Real gaussianDownsideDeviation() const
GenericGaussianStatistics()=default
Real gaussianShortfall(Real target) const
gaussian-assumption Shortfall (observations below target)
Real gaussianExpectedShortfall(Real percentile) const
gaussian-assumption Expected Shortfall at a given percentile
Real gaussianRegret(Real target) const
Stat::value_type value_type
Real gaussianValueAtRisk(Real percentile) const
gaussian-assumption Value-At-Risk at a given percentile
GenericGaussianStatistics(const Stat &s)
Real gaussianPercentile(Real percentile) const
Real gaussianPotentialUpside(Real percentile) const
gaussian-assumption Potential-Upside at a given percentile
Real gaussianTopPercentile(Real percentile) const
Inverse cumulative normal distribution function.
Normal distribution function.
Helper class for precomputed distributions.
StatsHolder(Real mean, Real standardDeviation)
Real standardDeviation() const
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
LinearInterpolation variance
GenericGaussianStatistics< GeneralStatistics > GaussianStatistics
default gaussian statistic tool
normal, cumulative and inverse cumulative distributions