Saturday 20 June 2015

Estimating Calories from random foods

Every piece of food you buy in Canada is equipped with a Nutrition Facts label.


This label presents an data total Calories, Fibre, Fat, Sodium, Carbs, Protein and micronutrients per serving. Of those, only protein, fat, and carbs contribute meaningfully to total calories. There are some odd trends in the labelling practises. For instance "Fat" and "Carbohydrates" have a "% Daily Value" (%DV) associated with them, but not protein. This is odd, since recommended protein intake is much easier to estimate a priori than either carbs or fat (more on that later). It's also odd that %DV of total calories is not given, since fat and carbs (whose recommended percentages are given) make up the bulk of food calories. Yet so much data is given, seems we could figure this out. Is it possible to reverse engineer the nutrition data given, make some simple assumptions, and sneakily obtain total recommended daily calories?

My Goal: using only the packaging of random food items (and one assumption about protein intake), I will determine the tacit daily caloric intake made by Health Canada.


It's hard just by looking to infer this, but some basic (matrix) math will help us here. For starters, there are 4 unknowns: the caloric density of Carb, Fat, & Protein, and the %DV of protein. Sure we could look up all 4 values (I do happen to know what these densities should be), but instead we will solve the first three using various household foods, then figure out the 4th with some guesstimates. I grabbed three items from my kitchen: a can of kidney beans, some liver pate, and cheese dip. They are relatively high in carbs, protein, and fat, respectively.

Three items from my kitchen: Beans, Dip, and Liver Pate, all labeled by Health Canada guidelines
 I wrote down their respective mass per serving of carbs, fats and protein. Remember than all that any other information included on the label (e.g. fibre, vitamins) does not concern us here. Let us also define the densities of each nutrient by the constants F, C, and P (units: Calories per gram). If we multiply these densities (presently unknown) by the mass given in the label, this should equal the total calories given at the top of the packages:


We can re-write this as a matrix, and solve for F, C, and P (I used Matlab, but doing by hand is also fine, just slower):


And voila! We have determined from three semi-random foods the caloric density of Fat, Carbs, and Protein is 9.4, 4.7, and 2.3 C/g, respectively. Is this true? Let's pick a fourth random item, some indian snacks, and find out. This label tells us that together 16g of fat, 27g of carbs, and 5g of protein will equal 270 Calories.

Some indian snacks, used for the purposes of testing (and snacking)  
I'll use my [F,C,P] array to see if I can roughly guess the same total energy per serving:


I got 287 Calories, which is a relative error of only 6% compared with 270. Not bad. If I had done this with more goods, this estimate would certainly improve. By the way the real densities of F,C,and P are 9, 4, and 4 C/g. So it seems there were some rounding errors based on the stuff I chose.

Next we want the total calories per day, which HC has not-so-cleverly hidden from us. Again using the same indian snacks, 16g of fat and 27g of carbs are 25% & 9% of our recommended intake, respectively. The equation looks like this


I'll use the actual densities this time around, to avoid compounding errors. Also the recommended intake of protein is rather well-agreed upon by nutritional scientists at 56 g/day (more generally 0.80 g/kg or 0.36 g/lb bodyweight). Hence for our indian snack equation 5g/56g = 0.09 or 9% DV.
Adding this information and the real caloric densities together we get


Surprise! (well, not really, since many probably knew this that was HC's guideline all along). The total is not a secret, but it's clear they just picked a round number, and hoped this would help people when calculate their energetic needs. All this despite some needing a lot more than 2000, and others less. The labelling system is so messed up, as you can see, that I would not trust it for anything at all. There are changes being proposed, but it's weak stuff. Health Canada still trying to explain food to people as if it's their fault for not 'getting it'.

Nutritionally useless yes, but at the very least our food labels provided me some mid morning entertainment.