openGPMP
Open Source Mathematics Package
pdfs_ex.cpp
Go to the documentation of this file.
1 #include <iostream>
3 
4 int main() {
5  // Testing the PDF class methods
6  std::cout << "Bernoulli CDF at x=1, p=0.5: "
7  << gpmp::stats::PDF::bernoulli(1, 0.5) << std::endl;
8  std::cout << "Beta PDF at x=0.5, alpha=2, beta=2: "
9  << gpmp::stats::PDF::beta(0.5, 2, 2) << std::endl;
10  std::cout << "Binomial PDF at k=2, n=5, p=0.5: "
11  << gpmp::stats::PDF::binomial(2, 5, 0.5) << std::endl;
12  std::cout << "Cauchy PDF at x=0, x0=0, gamma=1: "
13  << gpmp::stats::PDF::cauchy(0, 0, 1) << std::endl;
14  std::cout << "Chi-squared PDF at x=2, k=3: "
15  << gpmp::stats::PDF::chi_squared(2, 3) << std::endl;
16  std::cout << "Exponential PDF at x=1, lambda=0.5: "
17  << gpmp::stats::PDF::exponential(1, 0.5) << std::endl;
18  std::cout << "F Distribution PDF at x=1, df1=2, df2=3: "
19  << gpmp::stats::PDF::f_dist(1, 2, 3) << std::endl;
20  std::cout << "Gamma PDF at x=2, alpha=2, beta=0.5: "
21  << gpmp::stats::PDF::gamma(2, 2, 0.5) << std::endl;
22  std::cout << "Inverse-Gamma PDF at x=1, alpha=2, beta=0.5: "
23  << gpmp::stats::PDF::inverse_gamma(1, 2, 0.5) << std::endl;
24  std::cout << "Inverse-Gaussian PDF at x=1, mu=2, lambda=0.5: "
25  << gpmp::stats::PDF::inverse_gaussian(1, 2, 0.5) << std::endl;
26  std::cout << "Laplace PDF at x=1, mu=0, b=1: "
27  << gpmp::stats::PDF::laplace(1, 0, 1) << std::endl;
28  std::cout << "Logistic PDF at x=1, mu=0, s=1: "
29  << gpmp::stats::PDF::logistic(1, 0, 1) << std::endl;
30  std::cout << "Log-Normal PDF at x=2, mu=1, sigma=0.5: "
31  << gpmp::stats::PDF::log_normal(2, 1, 0.5) << std::endl;
32  std::cout << "Gaussian PDF at x=1, mu=0, sigma=1: "
33  << gpmp::stats::PDF::gaussian(1, 0, 1) << std::endl;
34  std::cout << "Poisson PDF at k=2, lambda=1: "
35  << gpmp::stats::PDF::poisson(2, 1) << std::endl;
36  std::cout << "Rademacher PDF at k=1: " << gpmp::stats::PDF::rademacher(1)
37  << std::endl;
38  std::cout << "Student's t PDF at x=1, df=2: "
39  << gpmp::stats::PDF::student_t(1, 2) << std::endl;
40  std::cout << "Uniform PDF at x=1, a=0, b=2: "
41  << gpmp::stats::PDF::uniform(1, 0, 2) << std::endl;
42  std::cout << "Weibull PDF at x=2, k=2, lambda=1: "
43  << gpmp::stats::PDF::weibull(2, 2, 1) << std::endl;
44 
45  return 0;
46 }
static double bernoulli(double x, double p)
Calculates the probability of success in a Bernoulli trial.
Definition: pdfs.cpp:44
static double gamma(double x, double alpha, double beta)
Calculates the probability density function (PDF) of the gamma distribution.
Definition: pdfs.cpp:106
static double beta(double x, double alpha, double beta)
Calculates the probability density function (PDF) of the Beta distribution.
Definition: pdfs.cpp:54
static double poisson(int k, double lambda)
Calculates the probability density function (PDF) of the Poisson distribution.
Definition: pdfs.cpp:160
static double gaussian(double x, double mu, double sigma)
Calculates the probability density function (PDF) of the Gaussian (normal) distribution.
Definition: pdfs.cpp:154
static double log_normal(double x, double mu, double sigma)
Calculates the probability density function (PDF) of the log-normal distribution.
Definition: pdfs.cpp:145
static double binomial(int k, int n, double p)
Calculates the probability of observing k successes in n independent Bernoulli trials.
Definition: pdfs.cpp:63
static double uniform(double x, double a, double b)
Calculates the probability density function (PDF) of the uniform distribution.
Definition: pdfs.cpp:186
static double f_dist(double x, int df1, int df2)
Calculates the probability density function (PDF) of the F distribution.
Definition: pdfs.cpp:95
static double exponential(double x, double lambda)
Calculates the probability density function (PDF) of the exponential distribution.
Definition: pdfs.cpp:87
static double inverse_gaussian(double x, double mu, double lambda)
Calculates the probability density function (PDF) of the inverse Gaussian distribution.
Definition: pdfs.cpp:125
static double inverse_gamma(double x, double alpha, double beta)
Calculates the probability density function (PDF) of the inverse gamma distribution.
Definition: pdfs.cpp:115
static double weibull(double x, double k, double lambda)
Calculates the probability density function (PDF) of the Weibull distribution.
Definition: pdfs.cpp:194
static double chi_squared(double x, int k)
Calculates the probability density function (PDF) of the chi-squared distribution.
Definition: pdfs.cpp:78
static double laplace(double x, double mu, double b)
Calculates the probability density function (PDF) of the Laplace distribution.
Definition: pdfs.cpp:134
static double cauchy(double x, double x0, double gamma)
Calculates the probability density function (PDF) of the Cauchy distribution.
Definition: pdfs.cpp:72
static double student_t(double x, int df)
Calculates the probability density function (PDF) of Student's t distribution.
Definition: pdfs.cpp:179
static double rademacher(int k)
Calculates the probability density function (PDF) of the Rademacher distribution.
Definition: pdfs.cpp:169
static double logistic(double x, double mu, double s)
Calculates the probability density function (PDF) of the logistic distribution.
Definition: pdfs.cpp:139
int main()
Definition: pdfs_ex.cpp:4