Home > matlab > missing > stats > chi2inv.m

chi2inv

PURPOSE ^

CHI2INV Quantile function of the chi-square distribution

SYNOPSIS ^

function inv = chi2inv (x, n)

DESCRIPTION ^

 CHI2INV  Quantile function of the chi-square distribution
  INV = chi2inv(X, N) computes, for each element of X, the
  quantile (the inverse of the CDF) at X of the chi-square
  distribution with N degrees of freedom.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function inv = chi2inv (x, n)
0002 % CHI2INV  Quantile function of the chi-square distribution
0003 %  INV = chi2inv(X, N) computes, for each element of X, the
0004 %  quantile (the inverse of the CDF) at X of the chi-square
0005 %  distribution with N degrees of freedom.
0006 
0007 % Adapted for Matlab (R) from GNU Octave 3.0.1
0008 % Original file: statistics/distributions/chi2inv.m
0009 % Original author: TT <Teresa.Twaroch@ci.tuwien.ac.at>
0010 
0011 % Copyright (C) 1995, 1996, 1997, 2005, 2006, 2007 Kurt Hornik
0012 % Copyright (C) 2008-2009 Dynare Team
0013 %
0014 % This file is part of Dynare.
0015 %
0016 % Dynare is free software: you can redistribute it and/or modify
0017 % it under the terms of the GNU General Public License as published by
0018 % the Free Software Foundation, either version 3 of the License, or
0019 % (at your option) any later version.
0020 %
0021 % Dynare is distributed in the hope that it will be useful,
0022 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0023 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0024 % GNU General Public License for more details.
0025 %
0026 % You should have received a copy of the GNU General Public License
0027 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0028 
0029 if (nargin ~= 2)
0030     error ('chi2inv: you must give two arguments');
0031 end
0032 
0033 if (~isscalar (n))
0034     [retval, x, n] = common_size (x, n);
0035     if (retval > 0)
0036         error ('chi2inv: x and n must be of common size or scalar');
0037     end
0038 end
0039 
0040 inv = gaminv (x, n / 2, 2);
0041 
0042 end

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