comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %
3 % Compute inverse of the Chi square cumulative distribution function
4 %
5 % CALL
6 %
7 % x = Chi2inv(p,v);
8 %
9 %
10 % INPUT
11 %
12 % - p, probability or significance level
13 % - v, degrees of freedom of the distribution
14 %
15 % Example: If you want the 95% confidence interval for a chi2 variable you
16 % should call
17 %
18 % x = utils.math.Chi2inv([0.05/2 1-0.05/2],v)
19 %
20 % References:
21 % [1] M. Abramowitz and I. A. Stegun, "Handbook of Mathematical
22 % Functions", Government Printing Office, 1964, 26.4.
23 %
24 %
25 % L Ferraioli 14-02-2011
26 %
27 % $Id: Chi2inv.m,v 1.2 2011/05/30 17:18:09 luigi Exp $
28 %
29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30 function x = Chi2inv(p,v)
31
32 a = v/2;
33 b = 2;
34 % Call the gamma inverse function.
35 % x = gaminv(p,v/2,2); % uses statistic toolbox
36 q = gammaincinv(p,a,'lower');
37 x = q.*b;
38
39
40 end