vnl_chi_squared.h
Go to the documentation of this file.
1 // This is core/vnl/algo/vnl_chi_squared.h
2 #ifndef vnl_chi_squared_h_
3 #define vnl_chi_squared_h_
4 #include "vnl/vnl_export.h"
5 #include <vnl/algo/vnl_algo_export.h>
6 //:
7 // \file
8 // \brief Name space for various (mostly templated) chi-squared distribution functions.
9 // \author Rupert Curwen, GE CRD
10 // \date August 18th, 1998
11 //
12 // \verbatim
13 // Modifications
14 // 26/03/2001 dac (Manchester) tidied up documentation
15 // 24 Mar 2010 Peter Vanroose made vnl_chi_squared_cumulative() templated
16 // \endverbatim
17 
18 //: Compute cumulative distribution function value for chi-squared distribution.
19 // This subroutine computes the cumulative distribution function
20 // value for the chi-squared distribution with integer degrees of
21 // freedom parameter = dof. This distribution is defined for all
22 // non-negative chisq. Thus if a random variable x is drawn from a
23 // chi-squared distribution with d degrees of freedom, then
24 // $P(x < X) =$ vnl_chi_squared_cumulative(X,d).
25 // Internally, T=double is used.
26 template <class T>
27 double vnl_chi_squared_cumulative(T chisq, long dof);
28 
29 //------------------------------------------------------------
30 
31 //: Name space for various chi-squared distribution functions.
32 //
33 // A[] and B[] are (pointers to) arrays containing histograms.
34 // If the 'normalize' parameter is true, each histogram will
35 // be implicitly normalized (so as to sum to 1) before the
36 // statistic is calculated :
37 //
38 // $a[i] = A[i] / \sum_j A[j]$
39 //
40 // $b[i] = B[i] / \sum_j B[j]$
41 //
42 // *DO NOT* add scale factors to these functions or you will break
43 // the code written by those who read the documentation. fsm.
44 //
45 // $\displaystyle \sum_i \frac{ (a[i] - b[i])^2 }{ a[i] } $
46 //
47 
48 template <class T>
49 double vnl_chi_squared_statistic_1 (T const *A, T const *B,
50  int n, bool normalize);
51 
52 //:
53 // $\displaystyle \sum_i \frac{ (a[i] - b[i])^2 }{ b[i] } $
54 template <class T>
55 double vnl_chi_squared_statistic_2 (T const *A, T const *B,
56  int n, bool normalize);
57 
58 //:
59 // $\displaystyle \sum_i \frac{ (a[i] - b[i])^2 }{ a[i] + b[i] } $
60 template <class T>
61 double vnl_chi_squared_statistic_12(T const *A, T const *B,
62  int n, bool normalize);
63 
64 #define VNL_CHI_SQUARED_INSTANTIATE(T) \
65 extern "please include vnl/algo/vnl_chi_squared.hxx first"
66 
67 #endif // vnl_chi_squared_h_
double vnl_chi_squared_cumulative(T chisq, long dof)
Compute cumulative distribution function value for chi-squared distribution.
double vnl_chi_squared_statistic_1(T const *A, T const *B, int n, bool normalize)
Name space for various chi-squared distribution functions.
double vnl_chi_squared_statistic_12(T const *A, T const *B, int n, bool normalize)
Data normalize(const vnl_bignum &b1, const vnl_bignum &b2, vnl_bignum &u, vnl_bignum &v)
normalize two vnl_bignums.
double vnl_chi_squared_statistic_2(T const *A, T const *B, int n, bool normalize)