Binomial
Create a new Binomial distribution
Binomial X = Binomial(n, p); Distribution properties:
Property
Type/Return type
Description
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.246094Binomial X = Binomial(25, -0.5); //Error: Probability cannot be less than 0 or more than 1.
std::cout << X.P(30) << std::endl; //Error: The number of succesful trials cannot exceed the number of all trials or be less than 0. Last updated