예제 #1
0
        private void Run()
        {
            List <(double, double)> spoints = Measurements.Select(_ => ((double)(_.Key - odt).TotalSeconds, _.Value)).ToList();

            var outgps = gpmm.AddTrainingPoints(spoints.Select(_ => _.Item1).ToArray(), spoints.Select(_ => _.Item2).ToArray());

            var xx = outgps.Select(_ => _.mu
                                   .Zip(_.sd95, (a, b) => new { Mu = a, Sigma = b })
                                   .Zip(_.X, (c, d) =>
                                        new Estimate(odt + TimeSpan.FromSeconds(d), c.Mu, c.Sigma)));

            Estimates.Clear();
            foreach (var __ in xx)
            {
                foreach (var ___ in __)
                {
                    Estimates.Add(___);
                }
            }
        }
예제 #2
0
        public void Run()
        {
            var filter = new UKF(1, 1);

            n = 1;
            q = 0.05;
            r = 0.3;
            N = 100;

            Q = Matrix.Build.Diagonal(n, n, q * q); //covariance of process
            NotifyChanged("Q");
            R = Matrix.Build.Dense(1, 1, r * r);    //covariance of measurement
            f = new FEquation();                    //nonlinear state equations
            h = new HEquation();                    //measurement equation
            x = q * Matrix.Build.Random(1, 1);      //s + q * Matrix.Build.Random(1, 1); //initial state with noise
            P = Matrix.Build.Diagonal(n, n, 1);     //initial state covariance


            var xV = Matrix.Build.Dense(n, N, 0); //Estimate
            var zV = Matrix.Build.Dense(1, N, 0); //measurement


            for (int k = 1; k < N; k++)
            {
                Matrix <double> z = ProcessBuilder.SineWave(k, r);
                //measurments

                Matrix <double>[] x_and_P = filter.Update(f, x, P, h, z, Q, R);                //ukf
                x = x_and_P[0];
                P = x_and_P[1];

                Measurements.Add(new Measurement()
                {
                    Value = z[0, 0], Time = TimeSpan.FromSeconds(k)
                });
                Estimates.Add(new Measurement()
                {
                    Value = x_and_P[0][0, 0], Time = TimeSpan.FromSeconds(k), Variance = x_and_P[1][0, 0]
                });
            }
        }
예제 #3
0
 public void Sample()
 {
     Estimates.Clear();
     gpw.Sample().ForEach(_ => Estimates.Add(_));
 }