Home > matlab > missing > stats > stdnormal_pdf.m

stdnormal_pdf

PURPOSE ^

STDNORMAL_PDF PDF of the standard normal distribution

SYNOPSIS ^

function pdf = stdnormal_pdf (x)

DESCRIPTION ^

 STDNORMAL_PDF  PDF of the standard normal distribution
  PDF = stdnormal_pdf(X)
  For each element of X, compute the PDF of the standard normal
  distribution at X.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function pdf = stdnormal_pdf (x)
0002 % STDNORMAL_PDF  PDF of the standard normal distribution
0003 %  PDF = stdnormal_pdf(X)
0004 %  For each element of X, compute the PDF of the standard normal
0005 %  distribution at X.
0006 
0007 % Adapted for Matlab (R) from GNU Octave 3.0.1
0008 % Original file: statistics/distributions/stdnormal_pdf.m
0009 % Original author: TT <Teresa.Twaroch@ci.tuwien.ac.at>
0010 
0011 % Copyright (C) 1995, 1996, 1997, 1998, 2000, 2002, 2004, 2005, 2006,
0012 %               2007 Kurt Hornik
0013 % Copyright (C) 2008-2009 Dynare Team
0014 %
0015 % This file is part of Dynare.
0016 %
0017 % Dynare is free software: you can redistribute it and/or modify
0018 % it under the terms of the GNU General Public License as published by
0019 % the Free Software Foundation, either version 3 of the License, or
0020 % (at your option) any later version.
0021 %
0022 % Dynare is distributed in the hope that it will be useful,
0023 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0024 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0025 % GNU General Public License for more details.
0026 %
0027 % You should have received a copy of the GNU General Public License
0028 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0029 
0030 if (nargin ~= 1)
0031     error('stdnormal_pdf: you should provide one argument');
0032 end
0033 
0034 sz = size(x);
0035 pdf = zeros (sz);
0036 
0037 k = find (isnan (x));
0038 if (any (k))
0039     pdf(k) = NaN;
0040 end
0041 
0042 k = find (~isinf (x));
0043 if (any (k))
0044     pdf (k) = (2 * pi)^(- 1/2) * exp (- x(k) .^ 2 / 2);
0045 end
0046 
0047 end

Generated on Tue 22-May-2012 02:40:23 by m2html © 2005