public void RunDelayed(double c, double d)
        {
            var meas = MathNet.Numerics.Generate.Sinusoidal(40, 1000, 100, 10)
                       .Select((_, i) => new KeyValuePair <DateTime, double>(new DateTime() + TimeSpan.FromHours(i), 20 + MathNet.Numerics.Distributions.Normal.Sample(_, 1)));

            var omeas = Observable.Interval(TimeSpan.FromSeconds(0.3)).Zip(meas.ToObservable(), (a, b) => b);

            var mw = new KalmanFilter.Wrap.DiscreteOuterWrapper(c, d, 1);

            var otpt = mw.Run(omeas.Select(_ => new KeyValuePair <DateTime, double?>(_.Key, _.Value)));

            Estimates         = new ObservableCollection <Estimate>();
            VelocityEstimates = new ObservableCollection <Estimate>();
            otpt.ObserveOnDispatcher().Subscribe(_ =>
            {
                Estimates.Add(new Estimate(_.Key, _.Value[0].Item1, _.Value[0].Item2));
                VelocityEstimates.Add(new Estimate(_.Key, _.Value[1].Item1, _.Value[1].Item2));
            });

            this.RaisePropertyChanged(nameof(Estimates));
            this.RaisePropertyChanged(nameof(VelocityEstimates));

            Measurements = new ObservableCollection <KeyValuePair <DateTime, double> >(meas);


            this.RaisePropertyChanged(nameof(Measurements));
        }
        public PredictionService5(IObservable <KeyValuePair <DateTime, Tuple <double, double> > > series, IScheduler scheduler)
        {
            var mw1 = new KalmanFilter.Wrap.DiscreteOuterWrapper(5, 5, 1);
            var mw2 = new KalmanFilter.Wrap.DiscreteOuterWrapper(5, 5, 1);

            var prs1 = mw1.Run(series.Select(_d => new KeyValuePair <DateTime, double?>(_d.Key, _d.Value.Item1)));
            var prs2 = mw2.Run(series.Select(_d => new KeyValuePair <DateTime, double?>(_d.Key, _d.Value.Item2)));

            Predictions = prs1.Zip(prs2, (c, d) => new KeyValuePair <DateTime, Tuple <double, double>[]>(c.Key, Combine(c.Value, d.Value)));
        }
        public void Run(double c, double d)
        {
            var meas = MathNet.Numerics.Generate.Sinusoidal(40, 1000, 100, 10)
                       .Select((_, i) => new KeyValuePair <DateTime, double>(new DateTime() + TimeSpan.FromSeconds(i), 20 + MathNet.Numerics.Distributions.Normal.Sample(_, 1)));

            Func <double, double, IEnumerable <KeyValuePair <DateTime, Tuple <double, double>[]> > > f = (a, b) =>
            {
                var mw = new KalmanFilter.Wrap.DiscreteOuterWrapper(a, b, 1);
                return(mw.BatchRun(meas));
            };

            var fcd = f(c, d);

            Estimates         = new ObservableCollection <Estimate>(fcd.Select(_ => new Estimate(_.Key, _.Value[0].Item1, _.Value[0].Item2)));
            VelocityEstimates = new ObservableCollection <Estimate>(fcd.Select(_ => new Estimate(_.Key, _.Value[1].Item1, _.Value[1].Item2)));

            this.RaisePropertyChanged(nameof(Estimates));
            this.RaisePropertyChanged(nameof(VelocityEstimates));
            Measurements = new ObservableCollection <KeyValuePair <DateTime, double> >(meas);


            this.RaisePropertyChanged(nameof(Measurements));
        }
        public PredictionService6(IObservable <KeyValuePair <DateTime, double> > series, IScheduler scheduler)
        {
            var mw1 = new KalmanFilter.Wrap.DiscreteOuterWrapper(5, 5, 1);

            Predictions = mw1.Run(series.Select(_ => new  KeyValuePair <DateTime, double?>(_.Key, _.Value)));
        }