Home > wafo > wstats > wnormpdf.m

# wnormpdf

## PURPOSE

Normal probability density function

## SYNOPSIS

f = wnormpdf(x,m,v);

## DESCRIPTION

``` WNORMPDF Normal probability density function

CALL:  f = wnormpdf(x,m,v);

f = density function evaluated at x
m = mean     (default 0)
v = variance (default 1)

Example:
x = linspace(-3,3,200);
p1 = wnormpdf(x,0,1); p2 = wnormpdf(x,.5,0.25);
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:
 chitwo2lc_sp Saddlepoint approximation of the crossing intensity for the noncentral Chi^2 process f_ar Auxiliary function used by RFCDEMO1 kdedemo1 Demonstrate the smoothing parameter impact on KDE lcplot Plots level-crossing spectrum (lc) specq2lc Saddlepoint approximation of the crossing intensity for the quadratic sea. wtpdf Student's T probability density function

## SOURCE CODE

```001 function f = wnormpdf(x,m,v);
002 %WNORMPDF Normal probability density function
003 %
004 % CALL:  f = wnormpdf(x,m,v);
005 %
006 %        f = density function evaluated at x
007 %        m = mean     (default 0)
008 %        v = variance (default 1)
009 %
010 % Example:
011 %   x = linspace(-3,3,200);
012 %   p1 = wnormpdf(x,0,1); p2 = wnormpdf(x,.5,0.25);
013 %   plot(x,p1,x,p2)
014
015
016 % Tested on; Matlab 5.3
017 % History:
018 % revised pab 9Aug2003
019 %  fixed a bug:
020 % revised pab 24.10.2000
021 %  - added comnsize, nargchk
022 %  - added default values
023 % added ms 15.06.2000
024
025 error(nargchk(1,3,nargin))
026 if nargin<2|isempty(m),  m=0;  end
027 if nargin<3|isempty(v),  v=1;  end
028
029 [errorcode, x, m, v] = comnsize (x,m, v);
030 if (errorcode > 0)
031   error ('x, m and v must be of common size or scalar');
032 end
033
034 f=zeros(size(x));
035
036 k = find (v>0);
037 if any(k)
038   f(k)=1./sqrt(2*pi*v(k)).*exp(-0.5*(x(k)-m(k)).^2./v(k));
039 end
040
041 k1 = find (v<=0);
042 if any (k1)
043   tmp=NaN;
044   f(k1) = tmp(ones(size(k1)));
045 end
046
047```

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