Pascal

Represents the number of trials required to achieve a specified number of successes in a sequence of independent and identically distributed Bernoulli trials. It generalizes the geometric distribution, which models the number of trials needed for a single success.

Create a new Pascal distribution

Pascal X = Pascal(r, p); 

creates a discrete Pascal probability distribution.

Distribution properties:

Property
Type/Return type
Description

r

int

Number of successes needed.

p

double -> [0, 1]

Probability of a successful trial.

E()

double

Returns the expected value of executed Bernoulli trials before hitting r successful trials.

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 observing the 𝑟-th success on the exactly 𝑘-th trial: P(X = k)

P_LT(int k)

double

Probability of observing the 𝑟-th success on the on less than 𝑘-th trials: P(X < k)

P_LTE(int k)

double

Probability of observing the 𝑟-th success on the on less than or exactly 𝑘-th trials: P(X ≤ k)

P_HT(int k)

double

Probability of observing the 𝑟-th success on the on more than 𝑘-th trials: P(X > k) = P(X ≤ k)

P_HTE(int k)

double

Probability of observing the 𝑟-th success on the on more than or exactly 𝑘-th trials: P(X ≥ k) = P(X < k)

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.060398

Good to know: k cannot be less than the number of required successful trials and probability p cannot be outside the bounds of [0, 1].

Last updated