Accelerating the pace of engineering and science

# geopdf

Geometric probability density function

y = geopdf(x,p)

## Description

y = geopdf(x,p) returns the probability density function (pdf) 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].

## Examples

expand all

### Compute Geometric Distribution pdf

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 exactly three tails ("failures") before tossing a heads?

To solve, determine the value of the probability density function (pdf) for the geometric distributon 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 = geopdf(x,p)
```
```y =

0.0625

```

The returned value of y indicates that the probability of observing exactly three tails before tossing a heads is 0.0625.

expand all

### Geometric Distribution pdf

The probability distribution function (pdf) of the geometric distribution is

$y=f\left(x|p\right)=p{\left(1-p\right)}^{x}\text{ };\text{ }x=0,1,2,\dots \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 exactly x trials before a success, when the probability of success in any given trial is p. For discrete distributions, the probability distribution function is also known as the probability mass function (pmf).