Mercurial > hg > ltpda
comparison m-toolbox/classes/+utils/@math/Fcdf.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 cumulative F distribution function | |
4 % | |
5 % CALL | |
6 % | |
7 % p = Fcdf(x,n1,n2); | |
8 % | |
9 % | |
10 % INPUT | |
11 % | |
12 % - x, probability | |
13 % - n1, degree of freedom 1 | |
14 % - n2, degree of freedom 2 | |
15 % | |
16 % References: | |
17 % [1] M. Abramowitz and I. A. Stegun, "Handbook of Mathematical | |
18 % Functions", Government Printing Office, 1964, 26.6. | |
19 % | |
20 % | |
21 % L Ferraioli 06-12-2010 | |
22 % | |
23 % $Id: Fcdf.m,v 1.1 2010/12/06 19:14:36 luigi Exp $ | |
24 % | |
25 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
26 function p = Fcdf(x,n1,n2) | |
27 | |
28 x = n2./(n2+x.*n1); | |
29 p = betainc(x, n2/2, n1/2, 'upper'); | |
30 | |
31 % % Compute P when X > 0. | |
32 % k = find(x > 0 & isfinite(n1) & isfinite(n2)); | |
33 % if any(k) | |
34 % k1 = (n2(k) <= x(k).*n1(k)); | |
35 % % use A&S formula 26.6.2 to relate to incomplete beta function | |
36 % % Also use 26.5.2 to avoid cancellation by subtracting from 1 | |
37 % if any(k1) | |
38 % kk = k(k1); | |
39 % xx = n2(kk)./(n2(kk)+x(kk).*n1(kk)); | |
40 % p(kk) = betainc(xx, n2(kk)/2, n1(kk)/2,'upper'); | |
41 % end | |
42 % if any(~k1) | |
43 % kk = k(~k1); | |
44 % num = n1(kk).*x(kk); | |
45 % xx = num ./ (num+n2(kk)); | |
46 % p(kk) = betainc(xx, n1(kk)/2, n2(kk)/2,'lower'); | |
47 % end | |
48 end |