HKWorkoutSession中的heartRate数据是否是移动平均线? [英] Is heartRate data from an HKWorkoutSession a moving average?
问题描述
我正在使用HKWorkoutSession在 workoutBuilder didCollectDataOf
中每5秒获取一次心率数据.心率报告为心跳/分钟".问题是,它们是作为移动平均值计算的,还是仅在前一个时间间隔内计算的?(我在任何地方的文档中都找不到此内容.)
I'm using an HKWorkoutSession to get heart rate data every 5 seconds in workoutBuilder didCollectDataOf
. The heart rates are reported as "beats/minute". The question is, are they calculated as moving averages, or just over the previous time interval? (I couldn't find this specified in the documentation anywhere.)
例如,如果您获得以下心率:
For example, if you get the following heart rates:
t=0: 69 beats/min
t=5: 71 beats/min
t=10: 72 beats/min
...
每个值是过去60秒的平均拍子间隔,还是只是从数据的最后5秒推断出来?
Is each value an average of beat intervals over the past 60 seconds, or is it just extrapolated from the last 5 seconds of data?
这是 didCollectDataOf
的样子:
func workoutBuilder(_ workoutBuilder: HKLiveWorkoutBuilder, didCollectDataOf collectedTypes: Set<HKSampleType>) {
for type in collectedTypes {
guard let hrType = HKQuantityType.quantityType(forIdentifier: .heartRate) else {
return
}
if collectedTypes.contains(hrType) {
if let hrQuantity = workoutBuilder.statistics(for: hrType)?.mostRecentQuantity() {
let hrUnit = HKUnit(from: "count/min")
let hr = Int(hrQuantity.doubleValue(for: hrUnit))
debugPrint("\(Date()) HR: \(hr)")
}
}
}
}
推荐答案
根据我的经验,这不是移动均线.
From my experience, it's not a moving average.
这篇关于HKWorkoutSession中的heartRate数据是否是移动平均线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!