-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathchi2calc.m
29 lines (25 loc) · 1010 Bytes
/
chi2calc.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function [p] = chi2calc(x,df)
%CHI2CALC - Returns the probability of a chi-square value
%
% function with V degrees of freedom at the values in X.
% The chi-square density function with DF degrees of freedom,
% is the same as a gamma density function with parameters V/2 and 2.
%
% The size of P is the common size of X and V. A scalar input
% functions as a constant matrix of the same size as the other input.
%
% This program calculates the chi-square significance values for given
% degrees of freedom and the tail probability (type I error rate) for
% given observed chi-square statistic and degree of freedom.
% Molecular Biology and Evolution Toolbox (MBEToolbox)
% Author: James Cai
% Email: jcai@tamu.edu
% Website: http://bioinformatics.org/mbetoolbox/
%
% $LastChangedDate: 2013-01-05 12:04:29 -0600 (Sat, 05 Jan 2013) $
% $LastChangedRevision: 327 $
% $LastChangedBy: jcai $
p=1-chi2cdf(x,df);
% find critical value
% critical = chi2inv(1-alpha, df);
% chi2inv(1-0.05,1)=3.8415