45 if (std::abs(x - 0) < std::numeric_limits<double>::epsilon())
47 else if (std::abs(x - 1) < std::numeric_limits<double>::epsilon())
58 return (std::pow(x, alpha - 1) * std::pow(1 - x, beta - 1)) /
59 beta_function(alpha, beta);
67 return binomial_coefficient(n, k) * std::pow(p, k) *
68 std::pow(1 - p, n - k);
73 return (1 / (M_PI * gamma)) *
74 (gamma * gamma / ((x - x0) * (x - x0) + gamma * gamma));
82 return (std::pow(x, k / 2.0 - 1) * std::exp(-x / 2.0)) /
83 (std::pow(2, k / 2.0) * std::tgamma(k / 2.0));
91 return lambda * std::exp(-lambda * x);
99 return std::pow(df1, df1 / 2.0) * std::pow(df2, df2 / 2.0) *
100 std::pow(x, df1 / 2.0 - 1) /
101 (std::pow(df2 + df1 * x, (df1 + df2) / 2.0) *
102 std::tgamma(df1 / 2.0) * std::tgamma(df2 / 2.0));
110 return (std::pow(x, alpha - 1) * std::exp(-x / beta)) /
111 (std::pow(beta, alpha) * std::tgamma(alpha));
119 return (std::pow(beta, alpha) * std::pow(x, -alpha - 1) *
120 std::exp(-beta / x)) /
129 return std::sqrt(lambda / (2 * M_PI * x * x * x)) *
130 std::exp(-lambda * (x - mu) * (x - mu) / (2 * mu * mu * x));
135 return 0.5 * std::exp(-std::abs(x - mu) / b) / b;
140 double z = (x - mu) / s;
141 return std::exp(-z) / (s * std::pow(1 + std::exp(-z), 2));
149 return (1 / (x * sigma * std::sqrt(2 * M_PI))) *
150 std::exp(-0.5 * std::pow((std::log(x) - mu) / sigma, 2));
155 return (1 / (sigma * std::sqrt(2 * M_PI))) *
156 std::exp(-0.5 * std::pow((x - mu) / sigma, 2));
164 return std::exp(-lambda) * std::pow(lambda, k) /
180 double numerator = std::tgamma((df + 1) / 2.0);
181 double denominator = std::sqrt(df * M_PI) * std::tgamma(df / 2.0);
182 return std::pow(1 + x * x / df, -(df + 1) / 2.0) * numerator / denominator;
187 if (x >= a && x <= b)
198 return (k / lambda) * std::pow(x / lambda, k - 1) *
199 std::exp(-std::pow(x / lambda, k));
205 for (
int i = 1; i <= k; ++i) {
206 result *=
static_cast<double>(n - (k - i)) / i;
213 return std::tgamma(alpha) * std::tgamma(beta) / std::tgamma(alpha + beta);
static T factorial(T n)
Calculates the factorial of the given integer or double.
static double bernoulli(double x, double p)
Calculates the probability of success in a Bernoulli trial.
static double gamma(double x, double alpha, double beta)
Calculates the probability density function (PDF) of the gamma distribution.
static double beta(double x, double alpha, double beta)
Calculates the probability density function (PDF) of the Beta distribution.
static double poisson(int k, double lambda)
Calculates the probability density function (PDF) of the Poisson distribution.
static double gaussian(double x, double mu, double sigma)
Calculates the probability density function (PDF) of the Gaussian (normal) distribution.
static double log_normal(double x, double mu, double sigma)
Calculates the probability density function (PDF) of the log-normal distribution.
static double binomial(int k, int n, double p)
Calculates the probability of observing k successes in n independent Bernoulli trials.
static double uniform(double x, double a, double b)
Calculates the probability density function (PDF) of the uniform distribution.
static double f_dist(double x, int df1, int df2)
Calculates the probability density function (PDF) of the F distribution.
static double exponential(double x, double lambda)
Calculates the probability density function (PDF) of the exponential distribution.
static double inverse_gaussian(double x, double mu, double lambda)
Calculates the probability density function (PDF) of the inverse Gaussian distribution.
static double inverse_gamma(double x, double alpha, double beta)
Calculates the probability density function (PDF) of the inverse gamma distribution.
static double weibull(double x, double k, double lambda)
Calculates the probability density function (PDF) of the Weibull distribution.
static double chi_squared(double x, int k)
Calculates the probability density function (PDF) of the chi-squared distribution.
static double laplace(double x, double mu, double b)
Calculates the probability density function (PDF) of the Laplace distribution.
static double cauchy(double x, double x0, double gamma)
Calculates the probability density function (PDF) of the Cauchy distribution.
static double student_t(double x, int df)
Calculates the probability density function (PDF) of Student's t distribution.
static double rademacher(int k)
Calculates the probability density function (PDF) of the Rademacher distribution.
static double logistic(double x, double mu, double s)
Calculates the probability density function (PDF) of the logistic distribution.
static double beta_function(double alpha, double beta)
Calculates the beta function.
static double binomial_coefficient(int n, int k)
Calculates the binomial coefficient "n choose k".
Miscellaneous utilities methods related to openGPMP.