Home > wafo > wstats > wexppdf.m

# wexppdf

## PURPOSE

Exponential probability density function

## SYNOPSIS

f = wexppdf(x,m);

## DESCRIPTION

``` WEXPPDF Exponential probability density function

CALL:  f = wexppdf(x,m);

f = density function evaluated at x
m = mean

The Exponential distribution is defined by its pdf

f(x)=exp(-x/m)/m, x>=0, m>0.

Example:
x = linspace(0,6,200);
p1 = wexppdf(x,1); p2 = wexppdf(x,2);
plot(x,p1,x,p2)```

## CROSS-REFERENCE INFORMATION

This function calls:
 comnsize Check if all input arguments are either scalar or of common size. error Display message and abort function. nan Not-a-Number.
This function is called by:

## SOURCE CODE

```001 function f = wexppdf(x,m);
002 %WEXPPDF Exponential probability density function
003 %
004 % CALL:  f = wexppdf(x,m);
005 %
006 %        f = density function evaluated at x
007 %        m = mean
008 %
009 % The Exponential distribution is defined by its pdf
010 %
011 %        f(x)=exp(-x/m)/m, x>=0, m>0.
012 %
013 % Example:
014 %   x = linspace(0,6,200);
015 %   p1 = wexppdf(x,1); p2 = wexppdf(x,2);
016 %   plot(x,p1,x,p2)
017
018 % Reference: Johnson, Kotz and Balakrishnan (1994)
019 % "Continuous Univariate Distributions, vol. 1", p. 494 ff
020 % Wiley
021
022 % Tested on; Matlab 5.3
023 % History:
024 %  Revised pab Dec2003
025 % fixed abug k1->k3
026 % revised pab 24.10.2000
027 %  - added comnsize, nargchk
029
030 error(nargchk(2,2,nargin))
031
032 [errorcode x m] = comnsize(x,m);
033 if errorcode > 0
034     error('x and m must be of common size or scalar.');
035 end
036
037 % Initialize f to zero.
038 f = zeros(size(x));
039
040 k=find(x >= 0 & m>0);
041 if any(k),
042   f(k)=exp(-x(k)./m(k))./m(k);
043 end
044
045 k3 = find(m<=0);
046 if any(k3)
047   tmp = NaN;
048   f(k3) = tmp(ones(size(k3)));
049 end
050
051
052```

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group

Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003