3

I've tried to keep this question as non-programmer-friendly as possible, but please let me know if you don't understand something.


I'm a software developer and I'm looking over some old code and I have come across a formula for working out calories burned.

METs = (1.5245 * milesPerHour) + 0.1128;
caloriesBurned = (durationMinutes * ((METs * 3.5 * kilograms) / 200.0f));

I can't figure out for definite what the unnamed arbitrary numbers are supposed to represent.

I did some research and found that the "normal" formula for working out calories burned is:

Energy (kcal) = METs * weight (kg) * time (hours)

I speculate that the numbers in the first equation have come about because someone just plugged some values into Excel and used the formula displayed on the trendline as an estimate.

The numbers in the second equation elude me completely. I thought it might be converting kJ to kcal, but the equation already outputs calories.

Then I noticed that the duration in the code is in minutes, but the formula I expect wants hours. However, (3.5/200) makes no sense converting from minutes to hours. (Coincidentally, it is a close approximation 0.016 ≈ 0.0175)


I think I've found the resource the original developer must have used:

Work Unit Conversions

1 MET = 3.5 ml/kg/min
1 MET = 1 kcal/kg/hr
...
METS to Kcal/min = multiply METS x 3.5 x body weight in kg then divide by 200

I still have no idea where that 200 comes from and I think the resource might be erroneous anyway as it seems to equate calories to mlO2


NB: I'm not looking for a new / "correct" formula, unfortunately I can't change this. However I'd like to be able to add comments to the code so that I can understand if / why it's wrong if I look at it again in the future.


TL;DR:

What do the arbitrary numbers mean in the above formulas?

  • What's metabolicRate in the second line? Where do you get it from? A MET is a unit for intensity, where one MET is defined as 3.5ml of oxygen per kg and per minute, so the 3.5 is just a number to get a good range of MET numbers, 1 MET is what you use for sitting. – Mårten Jul 21 '15 at 13:18
  • "metabolicRate" was just programming reference I had missed. It should read METs (and does now). I understand what the MET is and how it is normally used. I'm trying to get my head around what the previous programmer has done here and what the arbitrary numbers mean. – James Webster Jul 21 '15 at 13:20
  • Okay so 3.5 * nrMets * nrMinutes * nrKgs should be the number of ml of oxygen that you consume for a certain weight in a certain number of minutes, assuming there is a linear factor between calories consumed and milliliters of oxygen consumer, this code seems to assume that this factor is 200. Not sure if 200 is a good number, but it seems reasonable to me that the number isn't an exact one by nature, because biology. It is probably chosen to be easy to calculate with. – Mårten Jul 21 '15 at 13:24
  • assume is the word I'm worried about. It seems to have just been pulled out of nowhere. There is a equivalence of calories to ml of oxygen, but that factor is 3.5 * 60 = 210 (possibly just an error in the resource?). This can be seen by the equivalence of 1 MET = 3.5ml/kg/min ≣ 1 kcal/kg/hr ≣ 60 kcal/kg/min – James Webster Jul 21 '15 at 13:30
  • Okay, didn't know that, but that should depend on what you combust with the oxygen, right? Fat, protein and carbs should give a different amount of calories if you burn it with 1 ml of oxygen so to speak. Also, 210 = 200 for 1 significant figure. – Mårten Jul 21 '15 at 13:34
  • should depend on what you combust with the oxygen, right? In reality it will, but most of these equations are approximations anyway. Humans are complex after all and individual calorie burn will depend on a lot of factors – James Webster Jul 21 '15 at 13:35
  • I only made the realisation of the equivalence as I was writing that last comment, so it could well be just a rounding issue. – James Webster Jul 21 '15 at 13:35
  • Your METS equation is rather questionable. As walking at 4 mph is typically assigned a value of 5 METS, while your equation would estimate that activity at 6.2 METS. – arober11 Jul 21 '15 at 14:25
  • Yep. So questionable, that I questioned it here. (NB that I didn't write that equation, I'm not willing to take responsibility for it ;) ). I speculated that the equation is just a (poor) estimate based on some given values and blind trust of an Excel trendline. – James Webster Jul 21 '15 at 14:29
  • Also 1 MET = 1 Kcal / bodyMassKg * hour, so the caloriesBurned may also be a steaming pile. Though 3.5 is the constant used to convert between MET (vvo2max) and VO2, so may just be a doggy variable name. – arober11 Jul 21 '15 at 14:34
  • Good observation, I'd missed that! That resource has lots of errors then! Unfortunately I can't just "fix" this equation as it is also used on an Android app and a web service, not just the iOS app I've assumed responsibility for. – James Webster Jul 21 '15 at 14:41
  • What's the activity the MET equation is trying to approximate a value for? Curios as a number of published papers state there's a non linear relationship between speed and VO2. I'm also wondering if any of the coefficients are related to the: gradient, surface type, or wind resistance, as they appear in a number of the formula. – arober11 Jul 21 '15 at 14:48
  • 1
    It's for a run tracking application, so walking, jogging, running, skipping, etc. Any leg based propulsion outside. I also expect that walking should be a different equation to running as it requires less movement, not just slower movement. – James Webster Jul 21 '15 at 14:50
  • Hmm. I've found another resource which uses this magical 200: http://www.cmsfitnesscourses.co.uk/blog/53/using-mets-to-calculate-calories – James Webster Jul 21 '15 at 14:59
  • The 200 is just an algebraic manipulation, as: Kcal/Min ~= 5 * massKg * VO2 / 1000 = massKg * VO2 / 200, so if you change the METs variable name to vO2 the caloriesBurned formula appears textbook, well for short carbohydrate burns. After a few min's the body starts to burn fat as well as sugars, so the 5 drops to ~ 4.86. – arober11 Jul 21 '15 at 16:09

1 Answers1

1

If you grab yourself a copy of the Compendium of Physical Activities Unit-Conversions table, it may help.

Taking the second line first:

caloriesBurned = (durationMinutes * ((METs * 3.5 * kilograms) / 200.0f));

This appears to be a simple algebraic manipulation of the standard formula used to convert Oxygen consumption (Volume of O2 in litres [VO2]) into Kcals. Essentially your body requires Oxygen to convert the energy stored in its Sugars and Fats into ATP, to fuel your muscles, this process is called the Citric acid cycle.

The METs in that line is short for Metabolic Equivalent of Task, and is just an abstract way to quantify the relative energy cost of an activity, a number of sites offer MET estimates for specific activities eg.

Anyway:

MET       = 3.5 * VO2ml/massKg/min^-1

Kcal/Min ~= RespiratoryExchangeRatio * VO2litre / 1000
         ~= 5 * massKg * VO2litre / 1000 (sugar)   
         ~= massKg * VO2litre / 200 (sugar)        

Note: RespiratoryExchangeRatio is 5.0 for sugars, but drops to 4.86 for freeing energy from fat.

So for the first few mins of relative intensive exercise (ignore the first few secs, as anaerobic, and any fat burning after a few mins, or any sprints that will exceed your bodies ability to process ATP and result in a lactic acid build up) that bit of code appears correct:

 caloriesBurned = (durationMinutes * ((METs * 3.5 * kilograms) / 200.0f));

The worrying line is:

METs = (1.5245 * milesPerHour) + 0.1128;

As you've indicated the equation is being used as a general equation to estimate METS, for walking, jogging, running, skipping etc. But energy expenditure isn't linear, and there are other factors, such as gradient, wind resistance, surface, external weights..... that come into play in producing a MET score, even for a typical brisk walk, on the level it is incorrectly estimatied. As walking at 4 mph is typically assigned a value of 5 METS, while your equation would estimate that activity at 6.2 METS, overestimating calorie burn by 24%

arober11
  • 1,185
  • 7
  • 20