43 #include <boost/math/special_functions/fpclassify.hpp> 51 mean = var.mean() * coeff;
52 st_dev = var.standard_deviation() * coeff;
53 boost::math::normal s(mean, st_dev);
57 boost::math::normal
VarSum(boost::math::normal
x,
double c)
59 boost::math::normal s((x.mean() + c), x.standard_deviation());
63 boost::math::normal
VarSum(boost::math::normal
x, boost::math::normal y)
68 boost::math::normal
VarSum(boost::math::normal
x, boost::math::normal y,
double p)
71 mean = x.mean() + y.mean();
74 st_dev = sqrt(pow(x.standard_deviation(), 2) + pow(y.standard_deviation(), 2) +
75 2 * p * x.standard_deviation() * y.standard_deviation());
76 boost::math::normal s(mean, st_dev);
80 boost::math::lognormal
VarSum(std::vector<boost::math::lognormal> v)
84 boost::math::lognormal s = v.at(0);
85 for(
unsigned int i = 1; i < v.size(); i++)
91 return boost::math::lognormal();
94 boost::math::lognormal
VarSum(boost::math::lognormal
x, boost::math::lognormal y)
99 boost::math::lognormal
VarSum(boost::math::lognormal s1, boost::math::lognormal s2,
double p)
104 u1 =
exp(s1.location() + (pow(s1.scale(), 2)) / 2) +
exp(s2.location() + (pow(s2.scale(), 2)) / 2);
105 u2 =
exp(2 * s1.location() + 2 * pow(s1.scale(), 2)) +
exp(2 * s2.location() + 2 * pow(s2.scale(), 2)) +
106 2 *
exp(s1.location() + s2.location()) *
107 exp(0.5 * (pow(s1.scale(), 2) + pow(s2.scale(), 2) + 2 * p * s1.scale() * s2.scale()));
109 mean = 2 * log(u1) - 0.5 * log(u2);
110 st_dev = sqrt(log(u2) - 2 * log(u1));
112 boost::math::lognormal s(mean, st_dev);
116 boost::math::normal
VarMax(boost::math::normal
x, boost::math::normal y,
double p)
118 double mean = 0, st_dev = 0, var = 0;
119 double a = 0, alpha = 0;
121 a = pow((pow(x.standard_deviation(), 2) + pow(y.standard_deviation(), 2) -
122 2 * p * x.standard_deviation() * y.standard_deviation()),
124 alpha = (x.mean() + y.mean()) / a;
126 mean = x.mean() * cdf(x, alpha) + y.mean() * cdf(y, -alpha) + a * pdf(x, alpha);
127 var = (pow(x.standard_deviation(), 2) + pow(x.mean(), 2)) * cdf(x, alpha) +
128 (pow(y.standard_deviation(), 2) + pow(y.mean(), 2)) * cdf(y, -alpha) +
129 (x.mean() + y.mean()) * a * pdf(x, alpha) - pow(mean, 2);
132 boost::math::normal s(mean, st_dev);
136 boost::math::normal
VarMax(std::vector<boost::math::normal> v)
140 boost::math::normal s = v.at(0);
141 for(
unsigned int i = 1; i < v.size(); i++)
143 s =
VarMax(s, v.at(i), 0);
147 return boost::math::normal();
158 boost::math::lognormal v(s.mean(), s.standard_deviation());
165 v.reserve(static_cast<size_t>(n));
166 for(
int i = 0; i < n; i++)
175 double mean_rand,
double st_dev_rand)
177 boost::math::normal ris;
178 boost::math::normal x_rand(mean_rand, st_dev_rand);
183 boost::math::normal temp(mean, st_dev);
boost::math::normal MultiplyVarForCoefficient(int coeff, boost::math::normal var)
boost::math::normal CreateStatisticalAttribute(double a, int n)
boost::math::normal VarSum(boost::math::normal x, double c)
boost::math::lognormal ComputeStatisticalPower(double p, int n)
This file collects some algebric statistical functions.
boost::math::normal ComputeStatisticalDelay(double d, int n)
boost::math::normal VarMax(boost::math::normal x, boost::math::normal y, double p)
x
Return the smallest n such that 2^n >= _x.