Mercurial > hg > ltpda
diff m-toolbox/classes/+utils/@math/Chi2inv.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/classes/+utils/@math/Chi2inv.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,40 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Compute inverse of the Chi square cumulative distribution function +% +% CALL +% +% x = Chi2inv(p,v); +% +% +% INPUT +% +% - p, probability or significance level +% - v, degrees of freedom of the distribution +% +% Example: If you want the 95% confidence interval for a chi2 variable you +% should call +% +% x = utils.math.Chi2inv([0.05/2 1-0.05/2],v) +% +% References: +% [1] M. Abramowitz and I. A. Stegun, "Handbook of Mathematical +% Functions", Government Printing Office, 1964, 26.4. +% +% +% L Ferraioli 14-02-2011 +% +% $Id: Chi2inv.m,v 1.2 2011/05/30 17:18:09 luigi Exp $ +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +function x = Chi2inv(p,v) + +a = v/2; +b = 2; +% Call the gamma inverse function. +% x = gaminv(p,v/2,2); % uses statistic toolbox +q = gammaincinv(p,a,'lower'); +x = q.*b; + + +end \ No newline at end of file