Pascal
Create a new Pascal distribution
Pascal X = Pascal(r, p); Distribution properties:
Property
Type/Return type
Description
Example
//Example: A basketball player has a 20% chance of making a free throw.
//What's the probability of his 3rd successful free throw on his 10th attempt?
int r = 3; //number of successful events
double p = 0.2; //probability of a successful event
Pascal X = Pascal(r, p);
std::cout << X.P(10) << std::endl; //0.060398Pascal X = Pascal(5, 0.2); //Error: Probability cannot be less than 0 or more than 1.
std::cout << X.P(2) << std::endl; //Error: Number of trials cannot be less than the number of required successful trials. Last updated