Example #1
0
        /// <summary>
        /// Return true if within the confidence interval
        /// </summary>
        public static bool ChiSquaredTest(double confidenceInterval, Instances S, int attributeIndex, int targetAttributeIndex)
        {
            //attributeIndex = 89;

            double threshold = 1 - confidenceInterval;

            int    df = S.attribute(attributeIndex).numValues() - 1;
            double chiSquaredStatistic = ChiSquare.ApproximateChiSquared(S, attributeIndex, targetAttributeIndex);
            double pValue = ChiSquareUtils.pochisq(chiSquaredStatistic, df);

            Log.LogInfo("ChiSquared pValue is {0} and threshold is {1}", pValue, threshold);

            if (Double.IsNaN(pValue))
            {
                return(false);
            }
            else
            {
                bool result = (pValue <= threshold);
                return(result);
            }
        }