22#include <ql/math/statistics/incrementalstatistics.hpp>
32 return boost::accumulators::extract_result<
33 boost::accumulators::tag::count>(
acc_);
37 return boost::accumulators::extract_result<
38 boost::accumulators::tag::sum_of_weights>(
acc_);
42 QL_REQUIRE(
weightSum() > 0.0,
"sampleWeight_= 0, unsufficient");
43 return boost::accumulators::extract_result<
44 boost::accumulators::tag::weighted_mean>(
acc_);
48 QL_REQUIRE(
weightSum() > 0.0,
"sampleWeight_= 0, unsufficient");
49 QL_REQUIRE(
samples() > 1,
"sample number <= 1, unsufficient");
51 return n / (n - 1.0) *
52 boost::accumulators::extract_result<
53 boost::accumulators::tag::weighted_variance>(
acc_);
65 QL_REQUIRE(
samples() > 2,
"sample number <= 2, unsufficient");
67 Real r1 = n / (n - 2.0);
68 Real r2 = (n - 1.0) / (n - 2.0);
69 return std::sqrt(r1 * r2) *
70 boost::accumulators::extract_result<
71 boost::accumulators::tag::weighted_skewness>(
acc_);
76 "sample number <= 3, unsufficient");
77 boost::accumulators::extract_result<
78 boost::accumulators::tag::weighted_kurtosis>(
acc_);
80 Real r1 = (n - 1.0) / (n - 2.0);
81 Real r2 = (n + 1.0) / (n - 3.0);
82 Real r3 = (n - 1.0) / (n - 3.0);
83 return ((3.0 + boost::accumulators::extract_result<
84 boost::accumulators::tag::weighted_kurtosis>(
acc_)) *
91 QL_REQUIRE(
samples() > 0,
"empty sample set");
92 return boost::accumulators::extract_result<
93 boost::accumulators::tag::min>(
acc_);
97 QL_REQUIRE(
samples() > 0,
"empty sample set");
98 return boost::accumulators::extract_result<
99 boost::accumulators::tag::max>(
acc_);
103 return boost::accumulators::extract_result<
108 return boost::accumulators::extract_result<
109 boost::accumulators::tag::sum_of_weights>(
downsideAcc_);
116 Real r1 = n / (n - 1.0);
118 boost::accumulators::extract_result<
127 QL_REQUIRE(valueWeight >= 0.0,
"negative weight (" << valueWeight
129 acc_(value, boost::accumulators::weight = valueWeight);
131 downsideAcc_(value, boost::accumulators::weight = valueWeight);
Size samples() const
number of samples collected
Size downsideSamples() const
number of negative samples collected
Real downsideVariance() const
Real weightSum() const
sum of data weights
downside_accumulator_set downsideAcc_
void add(Real value, Real weight=1.0)
adds a datum to the set, possibly with a weight
Real downsideDeviation() const
boost::accumulators::accumulator_set< Real, boost::accumulators::stats< boost::accumulators::tag::count, boost::accumulators::tag::weighted_moment< 2 >, boost::accumulators::tag::sum_of_weights >, Real > downside_accumulator_set
boost::accumulators::accumulator_set< Real, boost::accumulators::stats< boost::accumulators::tag::count, boost::accumulators::tag::min, boost::accumulators::tag::max, boost::accumulators::tag::weighted_mean, boost::accumulators::tag::weighted_variance, boost::accumulators::tag::weighted_skewness, boost::accumulators::tag::weighted_kurtosis, boost::accumulators::tag::sum_of_weights >, Real > accumulator_set
Real errorEstimate() const
Real standardDeviation() const
Real downsideWeightSum() const
sum of data weights for negative samples
void reset()
resets the data to a null set
std::size_t Size
size of a container