Main Content

geoinv

Geometric inverse cumulative distribution function

Description

x = geoinv(y,p) returns the inverse cumulative distribution function (icdf) of the geometric distribution at each value in y using the corresponding probabilities in p.

example

Examples

collapse all

Suppose the probability of a five-year-old car battery not starting in cold weather is 0.03. If we want no more than a ten percent chance that the car does not start, what is the maximum number of days in a row that we should try to start the car?

To solve, compute the inverse cdf of the geometric distribution. In this example, a "success" means the car does not start, while a "failure" means the car does start. The probability of success for each trial p equals 0.03, while the probability of observing x failures in a row before observing a success y equals 0.1.

y = 0.1;
p = 0.03;
x = geoinv(y,p)
x = 
3

The returned result indicates that if we start the car three times, there is at least a ten percent chance that it will not start on one of those tries. Therefore, if we want no greater than a ten percent chance that the car will not start, we should only attempt to start it for a maximum of two days in a row.

We can confirm this result by evaluating the cdf at values of x equal to 2 and 3, given the probability of success for each trial p equal to 0.03.

y2 = geocdf(2,p)  % cdf for x = 2
y2 = 
0.0873
y3 = geocdf(3,p)  % cdf for x = 3
y3 = 
0.1147

The returned results indicate an 8.7% chance of the car not starting if we try two days in a row, and an 11.5% chance of not starting if we try three days in a row.

Input Arguments

collapse all

Probability values at which to evaluate the inverse of the cdf (icdf), specified as a scalar value or an array of scalar values in the range [0,1].

To evaluate the icdf at multiple values, specify y using an array. To evaluate the icdfs of multiple distributions, specify p using an array. If both of the input arguments y and p are arrays, then the array sizes must be the same. If only one of the input arguments is an array, then geoinv expands the scalar input into a constant array of the same size as the array input. Each element in x is the icdf value of the distribution specified by the corresponding element in p, evaluated at the corresponding element in y.

Data Types: single | double

Probability of success in a single trial, specified as a scalar or an array of scalars in the range [0,1].

To evaluate the icdf at multiple values, specify y using an array. To evaluate the icdfs of multiple distributions, specify p using an array. If both of the input arguments y and p are arrays, then the array sizes must be the same. If only one of the input arguments is an array, then geoinv expands the scalar input into a constant array of the same size as the array input. Each element in x is the icdf value of the distribution specified by the corresponding element in p, evaluated at the corresponding element in y.

Data Types: single | double

Output Arguments

collapse all

Inverse cdf values, returned as a scalar value or an array of scalar values. x is the same size as y and p after any necessary scalar expansion. For an element of x (x) and its corresponding elements in y and p (y and p), the cdf value x is the probability of having at most y trials before a success, when p is the probability of a success in any given trial.

geoinv returns the smallest positive integer x such that the geometric cdf evaluated at x is equal to or exceeds y. In other words, y is the probability of observing x successes in a row in independent trials, where p is the probability of success in each trial.

Alternative Functionality

  • geoinv is a function specific to the geometric distribution. Statistics and Machine Learning Toolbox™ also offers the generic function icdf, which supports various probability distributions. To use icdf, specify the probability distribution name and its parameters. Note that the distribution-specific function geoinv is faster than the generic function icdf.

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced before R2006a