Ejemplo n.º 1
0
        public IObservable <KeyValuePair <DateTime, Tuple <double, double>[]> > Run(IObservable <KeyValuePair <DateTime, double?> > meas)
        {
            ParticleFilterSharp1D FilterSharp = new ParticleFilterSharp1D();


            FilterSharp.Particles = ParticleFactory.BuildSwarm(N, new int[] { min, max }).ToList();


            return(meas.IncrementalTimeOffsets().Select(_ =>
            {
                // move based on last measurement
                FilterSharp.Predict(EffectiveCountMinRatio, _.Key.Item2);

                var prd = new KeyValuePair <DateTime, Tuple <double, double>[]>(
                    _.Key.Item1, FilterSharp.Particles.Select(__ => Tuple.Create(__.Y, __.Weight)).ToArray());


                // incorporate measurement
                if (_.Value != null)
                {
                    FilterSharp.Update(new Point(0, (double)_.Value));
                }


                return prd;
            }));
        }
Ejemplo n.º 2
0
        public IEnumerable <KeyValuePair <DateTime, Tuple <double, double>[]> > BatchRun1D(IEnumerable <KeyValuePair <DateTime, Point> > meas)
        {
            ParticleFilterSharp1D FilterSharp = new ParticleFilterSharp1D();


            FilterSharp.Particles = ParticleFactory.BuildSwarm(N, new int[] { min, max }).ToList();


            DateTime dt = meas.First().Key;

            foreach (var m in meas)
            {
                TimeSpan ticks = (m.Key - dt);

                // move based on last measurement
                FilterSharp.Predict(EffectiveCountMinRatio, ticks);

                var prd = new KeyValuePair <DateTime, Tuple <double, double>[]>(
                    m.Key, FilterSharp.Particles.Select(__ => Tuple.Create(__.Y, __.Weight)).ToArray());


                // incorporate measurement
                if (m.Value != default(Point))
                {
                    FilterSharp.Update(m.Value);
                }

                dt = m.Key;

                yield return(prd);
            }
            ;
        }
Ejemplo n.º 3
0
        public IEnumerable <KeyValuePair <DateTime, Tuple <double, double>[]> > BatchRun(IEnumerable <KeyValuePair <DateTime, double> > meas)
        {
            ParticleFilterSharp1D FilterSharp = new ParticleFilterSharp1D();


            FilterSharp.Particles = ParticleFactory.BuildSwarm(N, new int[] { min, max }).ToList();


            DateTime dt = meas.First().Key;

            return(meas.Select(_ =>
            {
                TimeSpan ticks = (_.Key - dt);

                // move based on last measurement
                FilterSharp.Predict(EffectiveCountMinRatio, ticks);

                var prd = new KeyValuePair <DateTime, Tuple <double, double>[]>(
                    dt, FilterSharp.Particles.Select(__ => Tuple.Create(__.Y, __.Weight)).ToArray());


                // incorporate measurement
                FilterSharp.Update(new Point(0, _.Value));

                dt = _.Key;

                return prd;
            }));
        }