Main Content

geoinv

Geometric inverse cumulative distribution function

Syntax

x = geoinv(y,p)

Description

x = geoinv(y,p)返回逆累积分布功能on (icdf) of the geometric distribution at each value inyusing the corresponding probabilities inp.

geoinvreturns the smallest positive integerxsuch that the geometric cdf evaluated atxis equal to or exceedsy. You can think ofyas the probability of observingxsuccesses in a row in independent trials, wherepis the probability of success in each trial.

yandpcan be vectors, matrices, or multidimensional arrays that all have the same size. A scalar input forporyis expanded to a constant array with the same dimensions as the other input. The values inpandymust lie on the interval[0,1].

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 trialpequals 0.03, while the probability of observingxfailures in a row before observing a successyequals 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 ofxequal to 2 and 3, given the probability of success for each trialpequal 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.

Extended Capabilities

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

Version History

Introduced before R2006a