Main Content

geopdf

Geometric probability density function

Syntax

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

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

To solve, determine the value of the probability density function (pdf) 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 = 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.

More About

collapse all

Geometric Distribution pdf

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

y=f(x|p)=p(1p)x;x=0,1,2,,

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 pdf is also known as the probability mass function (pmf).

Extended Capabilities

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

Version History

Introduced before R2006a