public void AddTest()
        {
            var X = new[] { 2003.0, 2001, 2004, 2000, 2002 };
            var Y = new[] { 6.93, 8.50, 6.60, 9.34, 7.62 };

            var ds = new XYDataSet(X, Y);
            Assert.AreEqual(2000, ds.XMin);
            Assert.AreEqual(2004, ds.XMax);
            Assert.AreEqual(6.60, ds.YMin);
            Assert.AreEqual(9.34, ds.YMax);
            Assert.AreEqual(2, ds.XMaxIndex);
            Assert.AreEqual(3, ds.XMinIndex);
            Assert.AreEqual(3, ds.YMaxIndex);
            Assert.AreEqual(2, ds.YMinIndex);
            Assert.AreEqual(-0.705, Math.Round(ds.Slope, 4));
            Assert.AreEqual(1419.208, Math.Round(ds.YIntercept, 4));
            Assert.AreEqual(2013.061, Math.Round(ds.XIntercept, 4));
            Assert.AreEqual(2002, Math.Round(ds.XMean, 4));
            Assert.AreEqual(7.798, Math.Round(ds.YMean, 4));

            ds.Add(2005, 5.90);
            Assert.AreEqual(2000, ds.XMin);
            Assert.AreEqual(2005, ds.XMax);
            Assert.AreEqual(5.90, ds.YMin);
            Assert.AreEqual(9.34, ds.YMax);
            Assert.AreEqual(5, ds.XMaxIndex);
            Assert.AreEqual(3, ds.XMinIndex);
            Assert.AreEqual(3, ds.YMaxIndex);
            Assert.AreEqual(5, ds.YMinIndex);
            Assert.AreEqual(-0.674, Math.Round(ds.Slope, 4));
            Assert.AreEqual(1357.1667, Math.Round(ds.YIntercept, 4));
            Assert.AreEqual(2013.6004, Math.Round(ds.XIntercept, 4));
            Assert.AreEqual(2002.5, Math.Round(ds.XMean, 4));
            Assert.AreEqual(7.4817, Math.Round(ds.YMean, 4));
        }
Beispiel #2
0
        public void ComputeRSquaredTest()
        {
            double[] X  = { 75.0, 83, 85, 85, 92, 97, 99 };
            double[] Y  = { 16.0, 20, 25, 27, 32, 48, 48 };
            var      ds = new XYDataSet(X, Y);

            var r2 = ds.ComputeRSquared();

            Assert.AreEqual(1.45, Math.Round(ds.Slope, 2));
            Assert.AreEqual(-96.85, Math.Round(ds.YIntercept, 2));
            Assert.AreEqual(0.927, Math.Round(r2, 3));

            Assert.AreEqual(0.927, Math.Round(ds.RSquare, 3));

            ds.Add(101, 51);

            Assert.AreEqual(double.NaN, Math.Round(ds.RSquare, 3));
        }
Beispiel #3
0
        public void ThisIndexTest()
        {
            var X  = new[] { 2003.0, 2001, 2004, 2000, 2002 };
            var Y  = new[] { 6.93, 8.50, 6.60, 9.34, 7.62 };
            var ds = new XYDataSet(X, Y);

            ds[3] = new PointD(2005, 5.90);
            Assert.AreEqual(2001, ds.XMin);
            Assert.AreEqual(2005, ds.XMax);
            Assert.AreEqual(5.90, ds.YMin);
            Assert.AreEqual(8.50, ds.YMax);
            Assert.AreEqual(-0.622, Math.Round(ds.Slope, 4));
            Assert.AreEqual(1252.976, Math.Round(ds.YIntercept, 4));
            Assert.AreEqual(2014.4309, Math.Round(ds.XIntercept, 4));

            ds.Add(2000, 9.34);
            Assert.AreEqual(2000, ds.XMin);
            Assert.AreEqual(2005, ds.XMax);
            Assert.AreEqual(5.90, ds.YMin);
            Assert.AreEqual(9.34, ds.YMax);
            Assert.AreEqual(-0.674, Math.Round(ds.Slope, 4));
            Assert.AreEqual(1357.1667, Math.Round(ds.YIntercept, 4));
            Assert.AreEqual(2013.6004, Math.Round(ds.XIntercept, 4));
        }
Beispiel #4
0
        public void AddTest()
        {
            var X = new[] { 2003.0, 2001, 2004, 2000, 2002 };
            var Y = new[] { 6.93, 8.50, 6.60, 9.34, 7.62 };

            var ds = new XYDataSet(X, Y);

            Assert.AreEqual(2000, ds.XMin);
            Assert.AreEqual(2004, ds.XMax);
            Assert.AreEqual(6.60, ds.YMin);
            Assert.AreEqual(9.34, ds.YMax);
            Assert.AreEqual(2, ds.XMaxIndex);
            Assert.AreEqual(3, ds.XMinIndex);
            Assert.AreEqual(3, ds.YMaxIndex);
            Assert.AreEqual(2, ds.YMinIndex);
            Assert.AreEqual(-0.705, Math.Round(ds.Slope, 4));
            Assert.AreEqual(1419.208, Math.Round(ds.YIntercept, 4));
            Assert.AreEqual(2013.061, Math.Round(ds.XIntercept, 4));
            Assert.AreEqual(2002, Math.Round(ds.XMean, 4));
            Assert.AreEqual(7.798, Math.Round(ds.YMean, 4));

            ds.Add(2005, 5.90);
            Assert.AreEqual(2000, ds.XMin);
            Assert.AreEqual(2005, ds.XMax);
            Assert.AreEqual(5.90, ds.YMin);
            Assert.AreEqual(9.34, ds.YMax);
            Assert.AreEqual(5, ds.XMaxIndex);
            Assert.AreEqual(3, ds.XMinIndex);
            Assert.AreEqual(3, ds.YMaxIndex);
            Assert.AreEqual(5, ds.YMinIndex);
            Assert.AreEqual(-0.674, Math.Round(ds.Slope, 4));
            Assert.AreEqual(1357.1667, Math.Round(ds.YIntercept, 4));
            Assert.AreEqual(2013.6004, Math.Round(ds.XIntercept, 4));
            Assert.AreEqual(2002.5, Math.Round(ds.XMean, 4));
            Assert.AreEqual(7.4817, Math.Round(ds.YMean, 4));
        }
        public void ThisIndexTest()
        {
            var X = new[] { 2003.0, 2001, 2004, 2000, 2002 };
            var Y = new[] { 6.93, 8.50, 6.60, 9.34, 7.62 };
            var ds = new XYDataSet(X, Y);

            ds[3] = new PointD(2005, 5.90);
            Assert.AreEqual(2001, ds.XMin);
            Assert.AreEqual(2005, ds.XMax);
            Assert.AreEqual(5.90, ds.YMin);
            Assert.AreEqual(8.50, ds.YMax);
            Assert.AreEqual(-0.622, Math.Round(ds.Slope, 4));
            Assert.AreEqual(1252.976, Math.Round(ds.YIntercept, 4));
            Assert.AreEqual(2014.4309, Math.Round(ds.XIntercept, 4));

            ds.Add(2000, 9.34);
            Assert.AreEqual(2000, ds.XMin);
            Assert.AreEqual(2005, ds.XMax);
            Assert.AreEqual(5.90, ds.YMin);
            Assert.AreEqual(9.34, ds.YMax);
            Assert.AreEqual(-0.674, Math.Round(ds.Slope, 4));
            Assert.AreEqual(1357.1667, Math.Round(ds.YIntercept, 4));
            Assert.AreEqual(2013.6004, Math.Round(ds.XIntercept, 4));
        }
        public void ComputeRSquaredTest()
        {
            double[] X = { 75.0, 83, 85, 85, 92, 97, 99 };
            double[] Y = { 16.0, 20, 25, 27, 32, 48, 48 };
            var ds = new XYDataSet(X, Y);

            var r2 = ds.ComputeRSquared();
            Assert.AreEqual(1.45, Math.Round(ds.Slope,2));
            Assert.AreEqual(-96.85, Math.Round(ds.YIntercept,2));
            Assert.AreEqual(0.927, Math.Round(r2, 3));

            Assert.AreEqual(0.927, Math.Round(ds.RSquare, 3));

            ds.Add(101, 51);

            Assert.AreEqual(double.NaN, Math.Round(ds.RSquare, 3));
        }