Ejemplo n.º 1
0
        public void TestMode()
        {
            var input    = new[] { 1.1, 1.1, 2, 3, 1, 2.5, 1.1, 459, 3.5, 1.1 };
            var expected = 1.1;

            Assert.AreEqual(expected, WaveMath.Mode(input));

            input    = new double[] { };
            expected = 0d;
            Assert.AreEqual(expected, WaveMath.Mode(input));

            input    = new[] { 1.1, 1.1, 2.2, 2.2 };
            expected = 1.1;
            Assert.AreEqual(expected, WaveMath.Mode(input));

            input    = new[] { 1.1, 1.1, 2.2, 2.2, 3.3, 3.3, 3.3 };
            expected = 3.3;
            Assert.AreEqual(expected, WaveMath.Mode(input));

            input    = new[] { 1.1, 1.1, 2.2, 2.2, 3.3, 3.3, 3.3, 1.1, 1.1, 2.2, 2.2, 1.1, 1.1, 2.2, 2.2, 3.3, 3.3, 3.3, 3.3, 3.3, 3.3, 1.1, 1.1, 2.2, 1.1, 1.1, 2.2, 2.2, 3.3, 3.3, 3.3, 2.2, 3.3, 3.3, 3.3, 1.1, 1.1, 2.2, 2.2, 3.3, 3.3, 3.3 };
            expected = 3.3;
            Assert.AreEqual(expected, WaveMath.Mode(input));
        }