21template <
typename RealType>
40 [[nodiscard]] std::string
Name()
const override;
42 [[nodiscard]] RealType
MinValue()
const override {
return 0; }
43 [[nodiscard]] RealType
MaxValue()
const override {
return INFINITY; }
49 [[nodiscard]]
double f(
const RealType &x)
const override;
50 [[nodiscard]]
double logf(
const RealType &x)
const override;
51 [[nodiscard]]
double F(
const RealType &x)
const override;
52 [[nodiscard]]
double S(
const RealType &x)
const override;
53 template <std::uniform_random_bit_generator G>
56 [[nodiscard]]
long double Mean()
const override;
57 [[nodiscard]]
long double Variance()
const override;
58 [[nodiscard]] RealType
Median()
const override;
59 [[nodiscard]] RealType
Mode()
const override;
60 [[nodiscard]]
long double Skewness()
const override;
64 RealType quantileImpl(
double p)
const override;
65 RealType quantileImpl1m(
double p)
const override;
66 std::complex<double> CFImpl(
double t)
const override;
74template <
typename RealType>
77 SetDegrees(degree1, degree2);
80template <
typename RealType>
83 return "Fisher-F(" + this->toStringWithPrecision(GetFirstDegree()) +
", " +
84 this->toStringWithPrecision(GetSecondDegree()) +
")";
87template <
typename RealType>
90 if (!(degree1 > 0 && degree2 > 0))
91 throw std::invalid_argument(
"F-distribution: degrees of should be positive");
96 B.SetShapes(0.5 * d1, 0.5 * d2);
99 d1_d2 =
static_cast<double>(d1) / d2;
100 c = -0.5 * (d1 + d2);
103 pdfCoef = (a + 1) * std::log(d1_d2);
104 pdfCoef -= B.GetLogBetaFunction();
107template <
typename RealType>
114 return std::exp(pdfCoef);
115 return (a > 0) ? 0.0 : INFINITY;
117 return std::exp(logf(x));
120template <
typename RealType>
128 return (a > 0) ? -INFINITY : INFINITY;
130 double y = a * std::log(x);
131 y += c * std::log1pl(d1_d2 * x);
135template <
typename RealType>
138 return B.F(d1_d2 * x);
141template <
typename RealType>
144 return B.S(d1_d2 * x);
147template <
typename RealType>
148template <std::uniform_random_bit_generator G>
154template <
typename RealType>
158 for (RealType &var : outputData)
162template <
typename RealType>
165 return (d2 > 2) ? 1 + 2.0 / (d2 - 2) : INFINITY;
168template <
typename RealType>
173 double variance = d2;
175 variance *= variance;
176 variance *= 2 * (d1 + d2 - 2);
182template <
typename RealType>
185 return d2_d1 * B.Median();
188template <
typename RealType>
193 return d2_d1 * (d1 - 2) / (d2 + 2);
196template <
typename RealType>
201 long double skewness = 8.0 * (d2 - 4.0);
202 long double aux = d1 + d2 - 2;
203 skewness /= d1 * aux;
204 skewness = std::sqrt(skewness);
205 skewness *= d1 + aux;
206 skewness /= d2 - 6.0;
210template <
typename RealType>
215 long double kurtosis = d2 - 2;
216 kurtosis *= kurtosis;
219 kurtosis /= d1 + d2 - 2;
220 kurtosis += 5 * d2 - 22;
223 return 12.0 * kurtosis;
226template <
typename RealType>
232template <
typename RealType>
233RealType FisherFRand<RealType>::quantileImpl1m(
double p)
const
235 return d2_d1 * B.Quantile1m(p);
238template <
typename RealType>
239std::complex<double> FisherFRand<RealType>::CFImpl(
double t)
const
241 return B.CF(d2_d1 * t);
The BetaPrimeRand class Beta-prime distribution.
Definition beta_prime.hpp:32
The ContinuousDistribution class Abstract class for all continuous distributions.
Definition continuous.hpp:22
The FisherFRand class F-distribution.
Definition fisher_f.hpp:23
double logf(const RealType &x) const override
Definition fisher_f.hpp:121
double F(const RealType &x) const override
Definition fisher_f.hpp:136
long double Variance() const override
Definition fisher_f.hpp:169
Support SupportType() const override
Definition fisher_f.hpp:41
RealType operator()(G &g) const
Definition fisher_f.hpp:149
long double Skewness() const override
Definition fisher_f.hpp:197
long double ExcessKurtosis() const override
Definition fisher_f.hpp:211
std::string Name() const override
Definition fisher_f.hpp:81
double f(const RealType &x) const override
Definition fisher_f.hpp:108
void SetDegrees(int degree1, int degree2)
Definition fisher_f.hpp:88
RealType MaxValue() const override
Definition fisher_f.hpp:43
int GetSecondDegree() const noexcept
Definition fisher_f.hpp:47
RealType MinValue() const override
Definition fisher_f.hpp:42
int GetFirstDegree() const noexcept
Definition fisher_f.hpp:46
RealType Mode() const override
Mode is the value, which has the largest probability to happen, or, in the case of continuous distrib...
Definition fisher_f.hpp:189
FisherFRand(int degree1=2, int degree2=2)
Definition fisher_f.hpp:75
RealType Median() const override
Definition fisher_f.hpp:183
double S(const RealType &x) const override
Definition fisher_f.hpp:142
long double Mean() const override
Definition fisher_f.hpp:163
void Sample(std::span< T > outputData) const
Fills the output with variates drawn with the engine of this object.
Definition distribution.hpp:139
T Quantile(double p) const
Definition univariate.hpp:307
The EngineRef class Non-owning, type-erased reference to any uniform random bit generator.
Definition engine/uniform.hpp:116
Definition bivariate_normal.hpp:10
Support
Shape of the support of a univariate distribution.
Definition univariate.hpp:15