Home > wafo > wstats > wnormcdf.m

wnormcdf

PURPOSE ^

Normal cumulative distribution function

SYNOPSIS ^

F = wnormcdf(x,m,v);

DESCRIPTION ^

 WNORMCDF Normal cumulative distribution function 
  
  CALL:  F = wnormcdf(x,m,v); 
  
         F = distribution function evaluated at x 
         m = mean     (default 0) 
         v = variance (default 1) 
   
  Example:  
    x = linspace(-3,3,200); 
    p1 = wnormcdf(x,0,1); p2 = wnormcdf(x,.5,0.25); 
    plot(x,p1,x,p2)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function F = wnormcdf(x,m,v); 
002 %WNORMCDF Normal cumulative distribution function 
003 % 
004 % CALL:  F = wnormcdf(x,m,v); 
005 % 
006 %        F = distribution 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 = wnormcdf(x,0,1); p2 = wnormcdf(x,.5,0.25); 
013 %   plot(x,p1,x,p2) 
014  
015  
016 % Tested on; Matlab 5.3 
017 % History: 
018 % revised pab 23.03.2003 
019 % -changed call from erf to erfc in order  
020 %  to get more accurate lower probabilities 
021 % -added a fix up for a bug in erfcore    
022 % revised pab 24.10.2000 
023 %  - added comnsize, nargchk 
024 %  - added default values 
025 % added ms 15.06.2000 
026  
027 error(nargchk(1,3,nargin)) 
028 if nargin<2|isempty(m),  m=0;  end 
029 if nargin<3|isempty(v),  v=1;  end 
030  
031 [errorcode, x, m, v] = comnsize (x,m, v); 
032 if (errorcode > 0) 
033   error ('x, m and v must be of common size or scalar'); 
034 end 
035  
036 F=zeros(size(x)); 
037  
038 k = find (v>0); 
039 if any(k)  
040   z    = -(x(k)-m(k))./sqrt(2*v(k)); 
041   F(k) = 0.5.*erfc(z); 
042   % fix up for a bug in erfcore (Matlab R11 and earlier) 
043   F(k(isnan(z))) = NaN; 
044 end 
045  
046 k1 = find (v<=0); 
047 if any (k1) 
048   tmp=NaN; 
049   F(k1) = tmp(ones(size(k1))); 
050 end 
051

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