Categories &

Functions List

Function Reference: geopdf

statistics: y = geopdf (x, ps)

Geometric probability density function (PDF).

For each element of x, compute the probability density function (PDF) of the geometric distribution with probability of success parameter ps. The size of y is the common size of x and ps. A scalar input functions as a constant matrix of the same size as the other inputs.

The geometric distribution models the number of failures (x) of a Bernoulli trial with probability ps before the first success.

Further information about the geometric distribution can be found at https://en.wikipedia.org/wiki/Geometric_distribution

Input arguments must be double, single, or an integer type; logical and character arrays are rejected. Integer input is promoted to double, so the result is always a probability. MATLAB is inconsistent here: for several of the discrete distributions it returns the result in the integer class of the input, truncating a probability to 0 or 1.

See also: geocdf, geoinv, geornd, geofit, geostat

Source Code: geopdf

Plot various PDFs from the geometric distribution

 x = 0:10;
 y1 = geopdf (x, 0.2);
 y2 = geopdf (x, 0.5);
 y3 = geopdf (x, 0.7);
 plot (x, y1, '*b', x, y2, '*g', x, y3, '*r')
 grid on
 ylim ([0, 0.8])
 legend ({'ps = 0.2', 'ps = 0.5', 'ps = 0.7'}, 'location', 'northeast')
 title ('Geometric PDF')
 xlabel ('values in x (number of failures)')
 ylabel ('density')
plotted figure