#include #include #include #include #include "include/externs.h" #include "include/cephes.h" #include "include/matrix.h" /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * R A N K T E S T * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ int Rank(int n, BitSequence *epsilon) { int ret = 0; int N, i, k, r; double p_value, product, chi_squared, arg1, p_32, p_31, p_30, R, F_32, F_31, F_30; BitSequence **matrix = create_matrix(32, 32); N = n/(32*32); if ( isZero(N) ) { p_value = 0.00; } else { r = 32; /* COMPUTE PROBABILITIES */ product = 1; for ( i=0; i<=r-1; i++ ) product *= ((1.e0-pow(2, i-32))*(1.e0-pow(2, i-32)))/(1.e0-pow(2, i-r)); p_32 = pow(2, r*(32+32-r)-32*32) * product; r = 31; product = 1; for ( i=0; i<=r-1; i++ ) product *= ((1.e0-pow(2, i-32))*(1.e0-pow(2, i-32)))/(1.e0-pow(2, i-r)); p_31 = pow(2, r*(32+32-r)-32*32) * product; p_30 = 1 - (p_32+p_31); F_32 = 0; F_31 = 0; for ( k=0; k