示例#1
0
 public override PhiAccrualState Actual()
 {
     return(new PhiAccrualState()
     {
         History = HeartbeatHistory.Apply(_sampleSize.Get)
     });
 }
        public void StatisticsForHeartbeats_must_calculate_correct_mean_and_variance()
        {
            var samples = new[] { 100L, 200L, 125L, 340L, 130L };
            var stats   = samples.Aggregate(HeartbeatHistory.Apply(20), (current, stat) => current + stat);

            ShouldBe(stats.Mean, 179.0D, 0.00001);
            ShouldBe(stats.Variance, 7584.0D, 0.00001);
        }
示例#3
0
        public Player()
        {
            Heartbeat        starthb = new Heartbeat(0, DateTime.Now);
            List <Heartbeat> history = new List <Heartbeat>();

            HeartbeatHistory = history;
            HeartbeatHistory.Add(starthb);
            HeartbeatLatest = starthb;
        }
        public void StatisticsForHeartbeats_must_be_capped_by_the_specified_maxSampleSize()
        {
            var history3 = HeartbeatHistory.Apply(3) + 100 + 110 + 90;

            ShouldBe(history3.Mean, 100.0D, 0.00001D);
            ShouldBe(history3.Variance, 66.6666667D, 0.00001D);

            var history4 = history3 + 140;

            ShouldBe(history4.Mean, 113.333333D, 0.00001D);
            ShouldBe(history4.Variance, 422.222222D, 0.00001D);

            var history5 = history4 + 80;

            ShouldBe(history5.Mean, 103.333333D, 0.00001D);
            ShouldBe(history5.Variance, 688.88888889D, 0.00001D);
        }
示例#5
0
        public async void StartReadingHeartRate()
        {
            var services = await Sensor.GetServicesAsync();

            foreach (var service in services)
            {
                if (service.Name == "Heart Rate")
                {
                    var chars = await service.GetCharacteristicsAsync();

                    var       descs = await chars[0].GetDescriptorsAsync();
                    await     chars[0].StartUpdatesAsync();
                    Heartbeat hb;
                    chars[0].ValueUpdated += (s, e) =>
                    {
                        hb = new Heartbeat(e.Characteristic.Value[1], DateTime.Now);
                        HeartbeatHistory.Add(HeartbeatLatest);
                        HeartbeatLatest = hb;
                        Console.WriteLine("Hartslag: " + hb.HeartRate);
                    };
                }
            }
        }
        public void StatisticsForHeartbeats_must_have_zero_variance_for_one_sample()
        {
            var history = HeartbeatHistory.Apply(600) + 1000L;

            ShouldBe(history.Variance, 0.0, 0.00001D);
        }