Main Content

# geocdf

Geometric cumulative distribution function

## Syntax

```y = geocdf(x,p) y = geocdf(x,p,'upper') ```

## Description

`y = geocdf(x,p)` returns the cumulative distribution function (cdf) of the geometric distribution at each value in `x` using the corresponding probabilities in `p`. `x` and `p` can be vectors, matrices, or multidimensional arrays that all have the same size. A scalar input is expanded to a constant array with the same dimensions as the other input. The parameters in `p` must lie on the interval `[0,1]`.

`y = geocdf(x,p,'upper')` returns the complement of the geometric distribution cdf at each value in `x`, using an algorithm that more accurately computes the extreme upper tail probabilities.

## Examples

collapse all

Suppose you toss a fair coin repeatedly, and a "success" occurs when the coin lands with heads facing up. What is the probability of observing three or fewer tails ("failures") before tossing a heads?

To solve, determine the value of the cumulative distribution function (cdf) for the geometric distribution at x equal to 3. The probability of success (tossing a heads) p in any given trial is 0.5.

```x = 3; p = 0.5; y = geocdf(x,p)```
```y = 0.9375 ```

The returned value of y indicates that the probability of observing three or fewer tails before tossing a heads is 0.9375.

## More About

collapse all

### Geometric Distribution cdf

The cumulative distribution function (cdf) of the geometric distribution is

`$y=F\left(x|p\right)=1-{\left(1-p\right)}^{x+1}\text{\hspace{0.17em}};\text{\hspace{0.17em}}x=0,1,2,...\text{\hspace{0.17em}},$`

where p is the probability of success, and x is the number of failures before the first success. The result y is the probability of observing up to x trials before a success, when the probability of success in any given trial is p.

## See Also

### Topics

Introduced before R2006a

Download ebook