comparison m-toolbox/classes/+utils/@math/Ftest.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 % Ftest perfomes an F-Test.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: SFT performes an F-Test providing the measured F statistic,
5 % the two degrees of freedom, the confidence level and the
6 % type of the test (a boolean, one or two tailed). The null
7 % hypothesis H0 is rejected at the confidence level for the
8 % alternative hypothesis H1 if the test statistic falls in the
9 % critical region.
10 %
11 % VERSION: $Id: Ftest.m,v 1.2 2011/03/07 16:50:47 congedo Exp $
12 %
13 % HISTORY: 18-02-2011 G. Congedo
14 %
15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16
17 function [test,critValue,pValue] = Ftest(F,dof1,dof2,alpha,twoTailed)
18
19 n = numel(F);
20
21 if twoTailed
22 % Lower bound
23 % critValue(1) = icdf('f',alpha/2,dof1,dof2);
24 critValue(1) = utils.math.Finv(alpha/2/n,dof1,dof2);
25 % Upper bound
26 % critValue(2) = icdf('f',1-alpha/2,dof1,dof2);
27 critValue(2) = utils.math.Finv(1-alpha/2/n,dof1,dof2);
28 else
29 % critValue = icdf('f',1-alpha,dof1,dof2);
30 critValue = utils.math.Finv(1-alpha/n,dof1,dof2);
31 end
32
33 % pValue = 1-cdf('f',F,dof1,dof2);
34 pValue = 1-utils.math.Fcdf(F,dof1,dof2);
35
36 if twoTailed
37 test = F<critValue(1) | F>critValue(2);
38 else
39 test = F>critValue;
40 end
41
42 end