Example #1
0
        public void TestGetSampledPoint()
        {
            double[] linear = new double[1000];
            linear[0] = 0.1;
            for (int n = 1; n < 1000; n++)
            {
                linear[n] = linear[n - 1] + 1.0;
            }
            ChaosAnalysis analysis   = new ChaosAnalysis();
            TimeSpan      sampleTime = new TimeSpan(1, 0, 0);
            DateTime      start      = new DateTime(2000, 1, 1);

            analysis.LoadSampledData(linear, start, sampleTime);
            analysis.CalculateMeasures(true, false, true);
            DateTime offset1 = start + new TimeSpan(sampleTime.Ticks * 3 + sampleTime.Ticks / 2);

            Assert.AreEqual(3.1, analysis.GetSampledPoint(offset1));
            analysis.interpolation = true;
            Assert.AreEqual(3.6, analysis.GetSampledPoint(offset1), 0.01);
            DateTime offset2 = start - new TimeSpan(sampleTime.Ticks * 3 + sampleTime.Ticks / 2);

            Assert.AreEqual(0.0, analysis.GetSampledPoint(offset2), 0.01);
            DateTime offset3 = analysis.latest + new TimeSpan(sampleTime.Ticks * 3 + sampleTime.Ticks / 2);

            Assert.AreEqual(999.1, analysis.GetSampledPoint(offset3), 0.01);
        }