public HarmonicMethod(List<Sample> samples)
        {
            this.regression = new HarmonicRegression();
            this.samples = samples;

            this.CalculateModel();
        }
Exemplo n.º 2
0
        private static void HarmonicRegressionTest()
        {
            var samples = new List<Sample>();
            samples.Add(new Sample() { Time = 1, Value = 0 });
            samples.Add(new Sample() { Time = 2, Value = 0.5 });
            samples.Add(new Sample() { Time = 3, Value = 1 });
            samples.Add(new Sample() { Time = 4, Value = 0.5 });
            samples.Add(new Sample() { Time = 5, Value = 0 });
            samples.Add(new Sample() { Time = 6, Value = -0.5 });
            samples.Add(new Sample() { Time = 7, Value = -1 });
            samples.Add(new Sample() { Time = 8, Value = -0.5 });
            samples.Add(new Sample() { Time = 9, Value = 0 });
            samples.Add(new Sample() { Time = 10, Value = 0.5 });
            samples.Add(new Sample() { Time = 11, Value = 1 });
            samples.Add(new Sample() { Time = 12, Value = 0.5 });
            samples.Add(new Sample() { Time = 13, Value = 0 });
            samples.Add(new Sample() { Time = 14, Value = -0.5 });
            samples.Add(new Sample() { Time = 15, Value = -1 });
            samples.Add(new Sample() { Time = 16, Value = -0.5 });

            HarmonicRegression hr = new HarmonicRegression();

            var model = hr.GetModel(samples);

            for (int i = 0; i < 50; i++)
                Console.WriteLine("Time = {0}, Value = {1}", i, hr.Predict(model, i));

            Console.ReadKey();
        }