/** * Returns the Pvalue for a particular score * * @param score * @param n * @return */ protected static double scoreToPvalue(double score, int n) { if (n <= 20) { // calculate it from binomial distribution // EXPAND: waiting for tables from Dimaki } double mean = n * (n + 1.0) / 4.0; double variable = n * (n + 1.0) * (2.0 * n + 1.0) / 24.0; double z = (score - mean) / Math.sqrt(variable); return ContinuousDistributions.GaussCdf(z); }
/** * Checks the Critical Value to determine if the Hypothesis should be rejected * * @param score * @param is_twoTailed * @param aLevel * @return */ protected static boolean checkCriticalValue(double score, boolean is_twoTailed, double aLevel) { double probability = ContinuousDistributions.GaussCdf(score); boolean rejectH0 = false; double a = aLevel; if (is_twoTailed) { // if to tailed test then split the statistical significance in half a = aLevel / 2; } if (probability <= a || probability >= (1 - a)) { rejectH0 = true; } return rejectH0; }
/** * Returns the Pvalue for a particular score. * * @param score * @return */ protected static double scoreToPvalue(double score) { return ContinuousDistributions.GaussCdf(score); }
/** * Returns the Pvalue for a particular score * * @param score * @param n * @param k * @return */ protected static double scoreToPvalue(double score, int n, int k) { return 1.0 - ContinuousDistributions.ChisquareCdf(score, (n - 1) * (k - 1)); }