Difference between revisions of "Recipe/Theory/Distribution"

From Open Food Facts wiki
Jump to navigation Jump to search
(Created page with "In order to get an idea how a recipe changes depending on the ingredients, it is necessary to have an idea on the distribution of the nutritional values. Once we have an idea...")
 
Line 15: Line 15:
  
 
== Second look ==
 
== Second look ==
 +
A solution could be to get rid of these strange values. Using the standards approach of removing everything below and above a value based on 1.5 times the interquartile distance, we can redo the above graphs.
 +
 +
The Cullen and Frey graph then transforms to:
 +
[[File:AlmondsFatCullenfreyOutliersRemoved.png|400 oxpx|thumb|center|Almonds Fat Cullen and Frey polt with outliers removed.]]
 +
 +
The distribution is now very close to what we expect for a Gaussian distribution (the star). Looking at the density plot:
 +
[[File:AlmondsFatsDensityNoOutliers.png|400 px|thumb|center|Almonds Fats Density distribution without outliers]]
 +
The density plot seems to suggest that there are two Gaussian distributions, which might explain the offset in the Cullen and Frey plot.
 +
 +
The QQ-plot now behaves much better:
 +
[[File:AlmondsFatsQQPlotNoOutliers.png|thumb|center|Almonds Fats QQ-plot without outliers]]
 +
Note that the sample quantiles seem very similar at -1. I suspect that these are theoretical values taken from Ciqual or similar. Could this be an explanation for the second peak? The Ciqual value is 52.5

Revision as of 15:40, 19 February 2025

In order to get an idea how a recipe changes depending on the ingredients, it is necessary to have an idea on the distribution of the nutritional values. Once we have an idea of the distribution, we can estimate the deviations for each nutrient of an ingredient.

From a theoretical point of view we expect that each nutrient follows a beta distribution. The reason for this, is that the values are bounded on [0,1]. For values that are far enough away from 0 and 1, we probably will have a gaussian distribution. (there are already some wiki-pages on this. which?).

This page will do some more analysis on the distributions. For this the clean-up category of Almonds will be used.

First look

Using a Cullen and Frey graph we can find the most appropriate distribution that fits the data. For the fat percentage of almonds, this gives this graph:

Almonds fats Cullen and Frey

One can see that there is no distribution that fits the data (red dot) well. (do not understand the bootstrap dots). The actual distribution is much more distorted.

Another way to look at this is a Q-Q plot:

Almonds fats quantile-quantile plot

In this plot we expect the values to be around the line. There is clearly a large tail at the bottom end that distorts the distribution. There are clearly issues with these products and should be flagged as thus.

Second look

A solution could be to get rid of these strange values. Using the standards approach of removing everything below and above a value based on 1.5 times the interquartile distance, we can redo the above graphs.

The Cullen and Frey graph then transforms to:

Almonds Fat Cullen and Frey polt with outliers removed.

The distribution is now very close to what we expect for a Gaussian distribution (the star). Looking at the density plot:

Almonds Fats Density distribution without outliers

The density plot seems to suggest that there are two Gaussian distributions, which might explain the offset in the Cullen and Frey plot.

The QQ-plot now behaves much better:

Almonds Fats QQ-plot without outliers

Note that the sample quantiles seem very similar at -1. I suspect that these are theoretical values taken from Ciqual or similar. Could this be an explanation for the second peak? The Ciqual value is 52.5