Example #1
0
        public void Test_Height_Standard_Deviation()
        {
            List <Observation> obs = new List <Observation>()
            {
                new Observation {
                    Height = 65, Weight = 150
                }
                , new Observation {
                    Height = 68, Weight = 160
                }
                , new Observation {
                    Height = 70, Weight = 172
                }
                , new Observation {
                    Height = 72, Weight = 168
                }
                , new Observation {
                    Height = 76, Weight = 185
                }
            };
            // 65 + 68 + 70 + 72 + 76 = 351
            // 351 / 5 = 70.2 = mean
            // (65 - 70.2)^2 + (68 - 70.2)^2 + (70 - 70.2)^2 + (72 - 70.2)^2 + (76 - 70.2)^2 = 68.8
            // 68.8 / 5 = 13.76
            // sqrt 13.76 = 3.70944
            ObservationStatistics stats = ObservationStatistics.CalculateStatistics(obs);

            Assert.AreEqual(3.70944, stats.HeightStandardDeviation, 0.01);
        }
Example #2
0
        public void Test_Median_Weight_With_Known_Even_Item_List()
        {
            List <Observation> obs = new List <Observation>()
            {
                new Observation {
                    Height = 65, Weight = 150
                }
                , new Observation {
                    Height = 68, Weight = 160
                }
                , new Observation {
                    Height = 70, Weight = 172
                }
                , new Observation {
                    Height = 72, Weight = 168
                }
                , new Observation {
                    Height = 76, Weight = 185
                }
                , new Observation {
                    Height = 77, Weight = 181
                }
            };
            // 172 + 168 =
            // 340 / 2 = 170
            ObservationStatistics stats = ObservationStatistics.CalculateStatistics(obs);

            Assert.AreEqual(170.0f, stats.MedianWeight, 0.01);
        }
Example #3
0
        public void Test_Mean_Weight_With_Known_List()
        {
            List <Observation> obs = new List <Observation>()
            {
                new Observation {
                    Height = 65, Weight = 150
                }
                , new Observation {
                    Height = 68, Weight = 160
                }
                , new Observation {
                    Height = 70, Weight = 172
                }
                , new Observation {
                    Height = 72, Weight = 168
                }
                , new Observation {
                    Height = 76, Weight = 185
                }
            };
            // 150 + 160 + 172 + 168 + 185 = 835
            //  835 / 5 = 167
            ObservationStatistics stats = ObservationStatistics.CalculateStatistics(obs);

            Assert.AreEqual(167, stats.MeanWeight, 0.01);
        }
Example #4
0
        public void Test_Mean_Height_With_Known_List()
        {
            List <Observation> obs = new List <Observation>()
            {
                new Observation {
                    Height = 65, Weight = 150
                }
                , new Observation {
                    Height = 68, Weight = 160
                }
                , new Observation {
                    Height = 70, Weight = 172
                }
                , new Observation {
                    Height = 72, Weight = 168
                }
                , new Observation {
                    Height = 76, Weight = 185
                }
            };
            // 65 + 68 + 70 + 72 + 76 = 351
            // 351 / 5 = 70.2
            ObservationStatistics stats = ObservationStatistics.CalculateStatistics(obs);

            Assert.AreEqual(70.2, stats.MeanHeight, 0.01);
        }
Example #5
0
        public void Test_Smallest_Weight_Observation_With_Random_List()
        {
            List <Observation>    obs   = GetRandomOrderedObservationList();
            ObservationStatistics stats = ObservationStatistics.CalculateStatistics(obs);
            Observation           ob    = GetObservationWithPredicate(obs, (Observation lhs, Observation rhs) => { return(lhs.Weight > rhs.Weight); });

            Assert.AreEqual(ob.Weight, stats.LeastWeightObservation.Weight, 0.01);
        }
Example #6
0
        public void Test_Largest_Height_Observation_With_Random_List()
        {
            List <Observation>    obs   = GetRandomOrderedObservationList();
            ObservationStatistics stats = ObservationStatistics.CalculateStatistics(obs);
            Observation           ob    = GetObservationWithPredicate(obs, (Observation lhs, Observation rhs) => { return(lhs.Height < rhs.Height); });

            Assert.AreEqual(ob.Height, stats.GreatestHeightObservation.Height, 0.01);
        }
Example #7
0
        public void Test_Median_Height_With_Known_Odd_Item_List()
        {
            List <Observation> obs = new List <Observation>()
            {
                new Observation {
                    Height = 65, Weight = 150
                }
                , new Observation {
                    Height = 68, Weight = 160
                }
                , new Observation {
                    Height = 70, Weight = 172
                }
                , new Observation {
                    Height = 72, Weight = 168
                }
                , new Observation {
                    Height = 76, Weight = 185
                }
            };
            ObservationStatistics stats = ObservationStatistics.CalculateStatistics(obs);

            Assert.AreEqual(70.0f, stats.MedianHeight, 0.01);
        }
Example #8
0
 public void Test_ObservationStatistics_With_Null_List()
 {
     ObservationStatistics stats = ObservationStatistics.CalculateStatistics(null);
 }
Example #9
0
 public void Test_ObservationStatistics_With_Emtpy_List()
 {
     ObservationStatistics stats = ObservationStatistics.CalculateStatistics(new List <Observation>());
 }