public void ValidateDiscreteStatisticsToString()
        {
            DiscreteStatistics discreteStat1 = DiscreteStatistics.GetInstance(1);
            DiscreteStatistics discreteStat2 = DiscreteStatistics.GetMissingInstance;

            Assert.AreEqual(discreteStat1.Value.ToString((IFormatProvider)null), discreteStat1.ToString());
            Assert.AreEqual("Missing", discreteStat2.ToString());
        }
        public void ValidateDiscreteStatisticsGetHashCode()
        {
            DiscreteStatistics discreteStat = DiscreteStatistics.GetMissingInstance;

            Assert.AreEqual(discreteStat.GetHashCode(), MissingStatistics.GetInstance.GetHashCode());

            DiscreteStatistics discreteStat1 = DiscreteStatistics.GetInstance(1);

            Assert.AreEqual(discreteStat1.Value, discreteStat1.GetHashCode());
        }
示例#3
0
        public void ValidateIntToSufficientStatisticsConverter()
        {
            IntToSufficientStatisticsConverter itssConverter = new IntToSufficientStatisticsConverter();
            DiscreteStatistics discreteStat = DiscreteStatistics.GetInstance(1);
            int convertedInt = itssConverter.ConvertBackward(discreteStat);

            Assert.AreEqual(1, convertedInt);
            DiscreteStatistics convertedDiscreteStat = itssConverter.ConvertForward('1') as DiscreteStatistics;

            Assert.IsNotNull(convertedDiscreteStat);
        }
示例#4
0
        public void ValidateCharToSufficientStatisticsConverter()
        {
            CharToSufficientStatisticsConverter ctssConverter = new CharToSufficientStatisticsConverter();
            DiscreteStatistics discreteStat = DiscreteStatistics.GetInstance(1);
            char convertedChar = ctssConverter.ConvertBackward(discreteStat);

            Assert.AreEqual('1', convertedChar);
            BooleanStatistics convertedBooleanStat = ctssConverter.ConvertForward('1') as BooleanStatistics;

            Assert.AreEqual("1", convertedBooleanStat.ToString());
        }
        public void ValidateStatisticsListGetHashCode()
        {
            StatisticsList     statList     = new StatisticsList();
            GaussianStatistics gaussStat    = GaussianStatistics.GetInstance(2.33, 1.256, 7);
            DiscreteStatistics discreteStat = DiscreteStatistics.GetInstance(1);
            MissingStatistics  missingStat  = MissingStatistics.GetInstance;

            statList.Add(gaussStat);
            statList.Add(discreteStat);
            statList.Add(missingStat);
            Assert.AreEqual(-1032035030, statList.GetHashCode());
        }
        public void ValidateStatisticsListGetInstance()
        {
            GaussianStatistics gaussStat    = GaussianStatistics.GetInstance(2.33, 1.256, 7);
            DiscreteStatistics discreteStat = DiscreteStatistics.GetInstance(1);
            StatisticsList     statList     = StatisticsList.GetInstance(gaussStat);

            statList.Add(discreteStat);
            SufficientStatistics result = null;

            foreach (SufficientStatistics stat in statList)
            {
                Assert.IsTrue(SufficientStatistics.TryParse(stat.ToString(), out result));
            }
        }
        public void ValidateStatisticsListAsBooleanStatistics()
        {
            StatisticsList     statList     = new StatisticsList();
            GaussianStatistics gaussStat    = GaussianStatistics.GetInstance(2.33, 1.256, 7);
            DiscreteStatistics discreteStat = DiscreteStatistics.GetInstance(1);
            MissingStatistics  missingStat  = MissingStatistics.GetInstance;

            statList.Add(gaussStat);
            statList.Add(discreteStat);
            statList.Add(missingStat);
            BooleanStatistics dStat = statList.AsBooleanStatistics();

            Assert.AreEqual(statList, dStat.AsStatisticsList());
        }
        public void ValidateStatisticsListAsContinuousStatistics()
        {
            StatisticsList     statList     = new StatisticsList();
            GaussianStatistics gaussStat    = GaussianStatistics.GetInstance(2.33, 1.256, 7);
            DiscreteStatistics discreteStat = DiscreteStatistics.GetInstance(1);
            MissingStatistics  missingStat  = MissingStatistics.GetInstance;

            statList.Add(gaussStat);
            statList.Add(discreteStat);
            statList.Add(missingStat);
            ContinuousStatistics cStat = statList.AsContinuousStatistics();

            Assert.IsTrue(cStat.IsMissing());
        }
        public void ValidateStatisticsListEquals()
        {
            StatisticsList     statList     = new StatisticsList();
            GaussianStatistics gaussStat    = GaussianStatistics.GetInstance(2.33, 1.256, 7);
            DiscreteStatistics discreteStat = DiscreteStatistics.GetInstance(1);
            MissingStatistics  missingStat  = MissingStatistics.GetInstance;

            statList.Add(gaussStat);
            statList.Add(discreteStat);
            statList.Add(missingStat);
            StatisticsList clone = (StatisticsList)statList.Clone();

            Assert.IsTrue(statList.Equals(clone));
        }
        public void ValidateStatisticsListToString()
        {
            StatisticsList     statList     = new StatisticsList();
            GaussianStatistics gaussStat    = GaussianStatistics.GetInstance(2.33, 1.256, 7);
            DiscreteStatistics discreteStat = DiscreteStatistics.GetInstance(1);
            MissingStatistics  missingStat  = MissingStatistics.GetInstance;

            statList.Add(gaussStat);
            statList.Add(discreteStat);
            statList.Add(missingStat);
            string statString = statList.ToString();

            Assert.AreEqual(gaussStat.ToString() + ";" + discreteStat.ToString() + ";" + missingStat.ToString(), statString);
        }
示例#11
0
 public MultinomialToSufficientStatisticsConverter()
     : base(
         m => m.IsDefinite ? (SufficientStatistics)DiscreteStatistics.GetInstance(m.BestOutcome) : (SufficientStatistics)MultinomialStatistics.GetInstance(m),
         s =>
 {
     var mult = s as MultinomialStatistics;
     if (mult != null)
     {
         return(mult.Multinomial);
     }
     int i = (int)s.AsDiscreteStatistics();
     return(new Multinomial(i + 1, i));
 }
         )
 { }
示例#12
0
        public void ValidateContinuousStatisticsExplicitDiscrete()
        {
            DiscreteStatistics   discreteStat2 = DiscreteStatistics.GetInstance(5);
            ContinuousStatistics boolStat2     = (ContinuousStatistics)discreteStat2;

            Assert.AreEqual(5, (int)(DiscreteStatistics)boolStat2);

            DiscreteStatistics   discreteStat = DiscreteStatistics.GetMissingInstance;
            ContinuousStatistics boolStat1    = (ContinuousStatistics)discreteStat;

            Assert.AreEqual(discreteStat, (DiscreteStatistics)boolStat1);

            DiscreteStatistics discreteStat3 = null;

            Assert.IsNull((ContinuousStatistics)discreteStat3);
        }
        public void ValidateDiscreteStatisticsEquals()
        {
            SufficientStatistics suffStat     = null;
            DiscreteStatistics   discreteStat = DiscreteStatistics.GetMissingInstance;

            Assert.IsFalse(discreteStat.Equals(suffStat));

            suffStat = (SufficientStatistics)discreteStat;
            Assert.IsTrue(discreteStat.Equals(suffStat));

            discreteStat = DiscreteStatistics.GetInstance(1);
            suffStat     = (SufficientStatistics)discreteStat;
            Assert.IsTrue(discreteStat.Equals(suffStat));

            object suffStatObj = (object)discreteStat;

            Assert.IsTrue(discreteStat.Equals(suffStat));
        }
        public void ValidateStatisticsListRemoveRangeAndRemove()
        {
            StatisticsList       statList     = new StatisticsList();
            GaussianStatistics   gaussStat    = GaussianStatistics.GetInstance(2.33, 1.256, 7);
            DiscreteStatistics   discreteStat = DiscreteStatistics.GetInstance(1);
            ContinuousStatistics contStat     = ContinuousStatistics.GetInstance(2.333);
            MissingStatistics    missingStat  = MissingStatistics.GetInstance;
            BooleanStatistics    boolStat     = BooleanStatistics.GetInstance(true);

            statList.Add(gaussStat);
            statList.Add(discreteStat);
            statList.Add(contStat);
            statList.Add(missingStat);
            statList.Add(boolStat);
            Assert.AreEqual(5, statList.Count);
            statList.RemoveRange(3, 2);
            Assert.AreEqual(3, statList.Count);
            statList.Remove(2);
            Assert.AreEqual(2, statList.Count);
        }
        public void ValidateStatisticsListTryParse()
        {
            StatisticsList       statList     = new StatisticsList();
            GaussianStatistics   gaussStat    = GaussianStatistics.GetInstance(2.33, 1.256, 7);
            DiscreteStatistics   discreteStat = DiscreteStatistics.GetInstance(1);
            ContinuousStatistics contStat     = ContinuousStatistics.GetInstance(2.333);
            MissingStatistics    missingStat  = MissingStatistics.GetInstance;
            BooleanStatistics    boolStat     = BooleanStatistics.GetInstance(true);

            statList.Add(gaussStat);
            statList.Add(discreteStat);
            statList.Add(contStat);
            statList.Add(missingStat);
            statList.Add(boolStat);
            Assert.AreEqual(5, statList.Count);
            SufficientStatistics result = null;
            StatisticsList       statListSubSequence = (StatisticsList)statList.SubSequence(0, 2);

            Assert.IsTrue(StatisticsList.TryParse(statList.ToString(), out result));
            Assert.IsTrue(StatisticsList.TryParse(statListSubSequence.ToString(), out result));
        }
示例#16
0
        public void ValidateBooleanStatisticsExplicitDiscrete()
        {
            DiscreteStatistics discreteStat2 = DiscreteStatistics.GetInstance(5);
            BooleanStatistics  boolStat2     = (BooleanStatistics)discreteStat2;

            Assert.AreEqual(5, (int)(DiscreteStatistics)boolStat2);

            DiscreteStatistics discreteStat = DiscreteStatistics.GetMissingInstance;
            BooleanStatistics  boolStat1    = (BooleanStatistics)discreteStat;

            Assert.AreEqual(discreteStat, (DiscreteStatistics)boolStat1);

            DiscreteStatistics discreteStat3 = null;

            try
            {
                BooleanStatistics boolStat3 = (BooleanStatistics)discreteStat3;
                Assert.Fail();
            }
            catch (ArgumentException)
            {
                Console.WriteLine("BooleanStatistics : Successfully validated the BooleanStatistics(Discrete)");
            }
        }
        public void ValidateDiscreteStatistics()
        {
            DiscreteStatistics discreteStat = DiscreteStatistics.GetInstance(1);

            Assert.AreEqual(1, discreteStat.Value);
        }
示例#18
0
 public IntToSufficientStatisticsConverter() : base(i => DiscreteStatistics.GetInstance(i), stats => (int)stats.AsDiscreteStatistics())
 {
 }