[ | Date | | | 2022-12-20 22:17 -0500 | ] |
[ | Mod. | | | 2024-01-11 18:12 -0500 | ] |
[ | Current movie | | | Everyone Says I Love You | ] |
Approximately in September of 2022, Apple added a built-in app to iOS: Fitness. It has some overlap with existing built-in app Health, and I understand Fitness used to be exclusive to the Apple Watch.
Both employ gamification to motivate their users into being physically active. Health let me set a goal expressed as a daily walking distance, and, a long time ago, I set that to five kilometers. (Perhaps I inherited this setting from Google’s health app for Android.)
Fitness encourages me to “fill circles”, and suggested I try to reach 120 kilocalories a day.
This was bad! 120 active kilocalories turns out to correspond to around three walking kilometers. And, since gamification apparently works on me, this changed caused me to become a little bit less active than I used to be.
I had to fix this. And, to do so, I would have to compute how many kilocalories would be roughly equivalent to my previous goal of 5 km. Was the formula as simple as a multiplicative factor?
From the graph above, we can immediately tell that the ratio of kilometers to calories is not a constant; otherwise, all black dots would be perfectly aligned.
Of course, this doesn’t tell me what the formula is. It may include other variables such as flights of stairs climbed, or perhaps walking speed.
That is probably fine: I can still compute an average of kilocalories per kilometer over that period and use that to set my active calorie goal. A more complex statistical model seems overkill.
Dividing the total active kilocalories by the total kilometers walked over the study period, I get:
This, in turns, means that I should set my active kilocalorie goal to 200 if I want it to correspond to about five kilometers.
In the course of preparing this post, I learned, or re-learned, a few things:
yq can process XML (I used it to convert Apple’s Health XML export into JSON for further processing by a Perl script, outputting CSV suitable for consumption by Gnuplot).
yq --input-format xml --output-format json <export.xml >export.json
Apple’s export format for health data is baroque; it is XML that I could not immediately find a published schema for, with varying granularity depending on the type of measurement. For example, “active energy burned” has one record per day, but “distance walking running” splits a day into numerous intervals of variable lengths.
I had forgotten about all I used to know about Gnuplot, over the course of just a few years. I find it difficult to write Gnuplot scripts that look readable. Still, with some searching and perseverance, I was able to produce the output I intended to.
Quick links: