private void CheckValue(
     EventBean values,
     double avgE)
 {
     var avg = GetDoubleValue(ViewFieldEnum.WEIGHTED_AVERAGE__AVERAGE, values);
     Assert.IsTrue(DoubleValueAssertionUtil.Equals(avg, avgE, 6));
 }
Example #2
0
        public void TestCORREL()
        {
            BaseStatisticsBean stat = new BaseStatisticsBean();

            Assert.AreEqual(Double.NaN, stat.Correlation);
            Assert.AreEqual(0, stat.N);

            stat.AddPoint(1, 10);
            Assert.AreEqual(Double.NaN, stat.Correlation);
            Assert.AreEqual(1, stat.N);

            stat.AddPoint(2, 20);
            Assert.AreEqual(1d, stat.Correlation);
            Assert.AreEqual(2, stat.N);

            stat.AddPoint(1.5, 14);
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.Correlation, 0.993399268, PRECISION_DIGITS));
            Assert.AreEqual(3, stat.N);

            stat.AddPoint(1.4, 14);
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.Correlation, 0.992631989, PRECISION_DIGITS));
            Assert.AreEqual(4, stat.N);

            stat.RemovePoint(1.5, 14);
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.Correlation, 1, PRECISION_DIGITS));
            Assert.AreEqual(3, stat.N);

            stat.AddPoint(100, 1);
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.Correlation, -0.852632057, PRECISION_DIGITS));
            Assert.AreEqual(4, stat.N);
        }
Example #3
0
        private static void CheckValues(
            EventBean values,
            bool isFirst,
            bool isNewData,
            long countE,
            double sumE,
            double avgE,
            double stdevpaE,
            double stdevE,
            double varianceE)
        {
            var count = GetLongValue(ViewFieldEnum.UNIVARIATE_STATISTICS__DATAPOINTS, values);
            var sum = GetDoubleValue(ViewFieldEnum.UNIVARIATE_STATISTICS__TOTAL, values);
            var avg = GetDoubleValue(ViewFieldEnum.UNIVARIATE_STATISTICS__AVERAGE, values);
            var stdevpa = GetDoubleValue(ViewFieldEnum.UNIVARIATE_STATISTICS__STDDEVPA, values);
            var stdev = GetDoubleValue(ViewFieldEnum.UNIVARIATE_STATISTICS__STDDEV, values);
            var variance = GetDoubleValue(ViewFieldEnum.UNIVARIATE_STATISTICS__VARIANCE, values);

            Assert.AreEqual(count, countE);
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(sum, sumE, 6));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(avg, avgE, 6));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stdevpa, stdevpaE, 6));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stdev, stdevE, 6));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(variance, varianceE, 6));
            if (isFirst && !isNewData) {
                Assert.AreEqual(null, values.Get("Symbol"));
                Assert.AreEqual(null, values.Get("Feed"));
            }
            else {
                Assert.AreEqual(SYMBOL, values.Get("Symbol"));
                Assert.AreEqual(FEED, values.Get("Feed"));
            }
        }
        private void CheckValues(EventBean eventBean, double slopeE, double yinterceptE)
        {
            double slope      = GetDoubleValue(ViewFieldEnum.REGRESSION__SLOPE, eventBean);
            double yintercept = GetDoubleValue(ViewFieldEnum.REGRESSION__YINTERCEPT, eventBean);

            Assert.IsTrue(DoubleValueAssertionUtil.Equals(slope, slopeE, 6));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(yintercept, yinterceptE, 6));
        }
        private void CheckValue(EventBean values, double avgE)
        {
            double avg = GetDoubleValue(ViewFieldEnum.WEIGHTED_AVERAGE__AVERAGE, values);

            Assert.IsTrue(DoubleValueAssertionUtil.Equals(avg, avgE, 6));
            Assert.AreEqual(FEED, values.Get("Feed"));
            Assert.AreEqual(SYMBOL, values.Get("Symbol"));
        }
Example #6
0
        private void CheckValues(EventBean values, long countE, double sumE, double avgE, double stdevpaE, double stdevE, double varianceE)
        {
            var count    = GetLongValue(ViewFieldEnum.UNIVARIATE_STATISTICS__DATAPOINTS, values);
            var sum      = GetDoubleValue(ViewFieldEnum.UNIVARIATE_STATISTICS__TOTAL, values);
            var avg      = GetDoubleValue(ViewFieldEnum.UNIVARIATE_STATISTICS__AVERAGE, values);
            var stdevpa  = GetDoubleValue(ViewFieldEnum.UNIVARIATE_STATISTICS__STDDEVPA, values);
            var stdev    = GetDoubleValue(ViewFieldEnum.UNIVARIATE_STATISTICS__STDDEV, values);
            var variance = GetDoubleValue(ViewFieldEnum.UNIVARIATE_STATISTICS__VARIANCE, values);

            Assert.AreEqual(count, countE);
            Assert.AreEqual(sum, sumE);
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(avg, avgE, 6));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stdevpa, stdevpaE, 6));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stdev, stdevE, 6));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(variance, varianceE, 6));
        }
Example #7
0
        public void TestClone()
        {
            BaseStatisticsBean stat = new BaseStatisticsBean();

            stat.AddPoint(100, 10);
            stat.AddPoint(200, 20);

            BaseStatisticsBean cloned = (BaseStatisticsBean)stat.Clone();

            Assert.AreEqual(2, cloned.N);
            Assert.AreEqual(300d, cloned.XSum);
            Assert.AreEqual(150d, cloned.XAverage);
            Assert.AreEqual(30d, cloned.YSum);
            Assert.AreEqual(15d, cloned.YAverage);
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(cloned.XStandardDeviationPop, 50.0, PRECISION_DIGITS));
        }
Example #8
0
        public void TestStddev_STDEVPA()
        {
            BaseStatisticsBean stat = new BaseStatisticsBean();

            Assert.AreEqual(Double.NaN, stat.XStandardDeviationPop);
            Assert.AreEqual(Double.NaN, stat.YStandardDeviationPop);
            Assert.AreEqual(0, stat.N);

            stat.AddPoint(1, 10500);
            Assert.AreEqual(0.0d, stat.XStandardDeviationPop);
            Assert.AreEqual(0.0d, stat.YStandardDeviationPop);
            Assert.AreEqual(1, stat.N);

            stat.AddPoint(2, 10200);
            Assert.AreEqual(0.5d, stat.XStandardDeviationPop);
            Assert.AreEqual(150d, stat.YStandardDeviationPop);
            Assert.AreEqual(2, stat.N);

            stat.AddPoint(1.5, 10500);
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.XStandardDeviationPop, 0.40824829, PRECISION_DIGITS));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.YStandardDeviationPop, 141.4213562, PRECISION_DIGITS));
            Assert.AreEqual(3, stat.N);

            stat.AddPoint(-0.1, 10500);
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.XStandardDeviationPop, 0.777817459, PRECISION_DIGITS));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.YStandardDeviationPop, 129.9038106, PRECISION_DIGITS));
            Assert.AreEqual(4, stat.N);

            stat.RemovePoint(2, 10200);
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.XStandardDeviationPop, 0.668331255, PRECISION_DIGITS));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.YStandardDeviationPop, 0.0, PRECISION_DIGITS));
            Assert.AreEqual(3, stat.N);

            stat.AddPoint(0.89, 10499);
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.XStandardDeviationPop, 0.580102362, PRECISION_DIGITS));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.YStandardDeviationPop, 0.433012702, PRECISION_DIGITS));
            Assert.AreEqual(4, stat.N);

            stat.AddPoint(1.23, 10500);
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.XStandardDeviationPop, 0.543860276, PRECISION_DIGITS));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.YStandardDeviationPop, 0.4, PRECISION_DIGITS));
            Assert.AreEqual(5, stat.N);
        }
Example #9
0
        public void TestStddevAndVariance_STDEV()
        {
            BaseStatisticsBean stat = new BaseStatisticsBean();

            Assert.AreEqual(Double.NaN, stat.XStandardDeviationSample);
            Assert.AreEqual(Double.NaN, stat.XVariance);
            Assert.AreEqual(Double.NaN, stat.YStandardDeviationSample);
            Assert.AreEqual(Double.NaN, stat.YVariance);

            stat.AddPoint(100, -1);
            Assert.AreEqual(Double.NaN, stat.XVariance);
            Assert.AreEqual(Double.NaN, stat.XStandardDeviationSample);
            Assert.AreEqual(Double.NaN, stat.YVariance);
            Assert.AreEqual(Double.NaN, stat.YStandardDeviationSample);

            stat.AddPoint(150, -1);
            Assert.AreEqual(1250d, stat.XVariance);
            Assert.AreEqual(0d, stat.YVariance);
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.XStandardDeviationSample, 35.35533906, PRECISION_DIGITS));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.YStandardDeviationSample, 0, PRECISION_DIGITS));

            stat.AddPoint(0, -1.1);
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.XVariance, 5833.33333333, PRECISION_DIGITS));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.YVariance, 0.003333333, PRECISION_DIGITS));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.XStandardDeviationSample, 76.37626158, PRECISION_DIGITS));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.YStandardDeviationSample, 0.057735027, PRECISION_DIGITS));

            stat.RemovePoint(100, -1);
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.XVariance, 11250, PRECISION_DIGITS));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.YVariance, 0.005, PRECISION_DIGITS));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.XStandardDeviationSample, 106.0660172, PRECISION_DIGITS));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.YStandardDeviationSample, 0.070710678, PRECISION_DIGITS));

            stat.AddPoint(-149, 0);
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.XVariance, 22350.333333, PRECISION_DIGITS));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.YVariance, 0.37, PRECISION_DIGITS));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.XStandardDeviationSample, 149.5002787, PRECISION_DIGITS));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.YStandardDeviationSample, 0.608276253, PRECISION_DIGITS));
        }
Example #10
0
        public void TestLINEST()
        {
            BaseStatisticsBean stat = new BaseStatisticsBean();

            Assert.AreEqual(Double.NaN, stat.Slope);
            Assert.AreEqual(Double.NaN, stat.YIntercept);
            Assert.AreEqual(0, stat.N);

            stat.AddPoint(1, 15);
            Assert.AreEqual(Double.NaN, stat.Slope);
            Assert.AreEqual(Double.NaN, stat.YIntercept);
            Assert.AreEqual(1, stat.N);

            stat.AddPoint(2, 20);
            Assert.AreEqual(5d, stat.Slope);
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.YIntercept, 10, PRECISION_DIGITS));
            Assert.AreEqual(2, stat.N);

            stat.AddPoint(1, 17);
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.Slope, 4, PRECISION_DIGITS));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.YIntercept, 12, PRECISION_DIGITS));
            Assert.AreEqual(3, stat.N);

            stat.AddPoint(1.4, 14);
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.Slope, 3.731343284, PRECISION_DIGITS));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.YIntercept, 11.46268657, PRECISION_DIGITS));
            Assert.AreEqual(4, stat.N);

            stat.RemovePoint(1, 17);
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.Slope, 5.394736842, PRECISION_DIGITS));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.YIntercept, 8.421052632, PRECISION_DIGITS));
            Assert.AreEqual(3, stat.N);

            stat.AddPoint(0, 0);
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.Slope, 9.764150943, PRECISION_DIGITS));
            Assert.IsTrue(DoubleValueAssertionUtil.Equals(stat.YIntercept, 1.509433962, PRECISION_DIGITS));
            Assert.AreEqual(4, stat.N);
        }
Example #11
0
        private void CheckValues(EventBean values, double correlationE)
        {
            double correlation = GetDoubleValue(ViewFieldEnum.CORRELATION__CORRELATION, values);

            Assert.IsTrue(DoubleValueAssertionUtil.Equals(correlation, correlationE, 6));
        }