Binomial
Represents the number of successes in a fixed number of independent and identically distributed Bernoulli trials (each trial having two possible outcomes: success or failure)
Create a new Binomial distribution
Binomial X = Binomial(n, p);
creates a discrete Binomial probability distribution.
Distribution properties:
n
int
Number of executed events
p
double -> [0, 1]
Probability of a succesful event
E()
double
Returns the expected value of succesful events after executing n
independend events, all with constant probability of p
.
D()
double
Represents variance, that measures the spread of dispersion of the random variable around its expected value E(X).
P(int k)
double
Probability of obtaining exactly 𝑘 successes in 𝑛 trials: P(X = k)
P_LT(int k)
double
Probability of obtaining less than 𝑘 successes in 𝑛 trials: P(X < k)
P_LTE(int k)
double
Probability of obtaining less than or exactly 𝑘 successes in 𝑛 trials: P(X ≤ k)
P_HT(int k)
double
Probability of obtaining more than 𝑘 successes in 𝑛 trials: P(X > k) = P(X ≤ k)
P_HTE(int k)
double
Probability of obtaining more than or exactly 𝑘 successes in 𝑛 trials: P(X ≥ k) = P(X < k)
Example
//Example: what's the probability of getting exactly 5 heads
//when flipping a coin 10 times?
double p = 0.5; //probability of getting heads is 50%
int n = 10; //10 independed events
Binomial X = Binomial(n, p);
std::cout << X.P(5) << std::endl; //0.246094
Last updated