Difference between revisions of "Condition Effect Learning"

From AardRock Wiki
Jump to navigation Jump to search
(Notities toegevoegd)
m (<math>a = \frac{x_{tot}-(\mu_1+\mu_2+...)}{\sigma_1^2+\sigma_2^2+...}</math> is now correct)
 
(27 intermediate revisions by the same user not shown)
Line 1: Line 1:
This page reflects my idea about the Condition Effect Learning system. If you have comments, please dont delete text but add comments so I can reflect. See this as a first draft, which can be used as a basis for the Cheetah condition effect learning system.
This page reflects my idea about the Condition Effect Learning system. If you have comments, please dont delete text but add comments so I can reflect. See this as a first draft, which can be used as a basis for the Cheetah condition effect learning system.


As said in [[Advisory System]], Cheetah needs a system that learns about the effect of certain conditions. As you can read in [[Advisory System]], I think there are three kinds of conditions:
As said in [[Advisory System]], Cheetah needs a system that learns about the effect of certain conditions. Condtions are variables that have effect on blood glucose levels. As you can read in [[Advisory System]], conditions can be classified as follows:
# Certain conditions;
# Certain conditions: the effect is known and fixed. The effect is fixed, so the learning system will see the effect as certain.
# Predicted uncertain conditions;
# Uncertain conditions: the effect is not certain or not known yet. So, the effect is a prediction done by the system. The learning system tries to approve the prediction by looking at the past.
# Yet unpredicted conditions.


There are some comlications regarding learning about food effects. Since each human and each body is different, conditions dont always have a fixed certain effect. Food for instance has GI (Glucose Index) that tells about the effect of the food on BG (Blood Glucose) levels. Responses vary between individuals and between days as much as 20%. So, the food effect can be expressed as an effect range. E.g. a minimum and maximum BG effect. This also counts for responses to insuline and the effect of activities (like sports). Therefore, to account for individual and temporal differences, I think it is a good thing to generally express condition effect by a range instead of just a single number.
There are some complications regarding learning about condition (e.g. food) effects. Since each human and each body is different, conditions dont always have a fixed certain effect. Food for instance has a GL (Glycamic Load) that tells about the effect of the food on BG (Blood Glucose) levels. Food effect (response) varies between individuals and between days as much as 20%. Likewise, effect of insulin and activities varies between people and temporally. Therefore, to account for intra-individual and temporal differences, I think it is a good thing to generally express condition effect by a range instead of a simple number. Such a range could be a probability distribution, or expressed as (minimum,maximum) tuple. For Cheetah, 'Learning' about conditions means assigning a range or distribution to it. There are several levels of expressing such variation in terms of a range or distribution.
I solved the first one, but not yet the second.
# Learning a condition's effect by assigning it a minimal and maximal effect value. For example, a minimum and maximum BG effect.
# Learning a condition's effect by seeing it as a normally distributed random variable.


The effect of conditions types 2 and 3 should be induced by the learning system of Cheetah. Lets assume that at each blood glucose (BG) measurement, Cheetah starts the Condition Effect Learning (CEL) system. Then, the &Delta;G(min and max) is calculated: the difference between predicted(min and max) and measured BG levels. Also, the set C of all type 2 and 3 conditions is assembled:
== 1. Learning a condition's effect by assigning it a minimal and maximal effect value ==
With this system, all conditions X have a X<sub>hardmin</sub> and X<sub>hardmax</sub> variables which tells the system the hard minimum and maximum of effect. For example, [http://www.ajcn.org/cgi/content/full/76/1/5/T1 research] has pointed out that a can of Coca-Cola has a Glycemic Load (GL) of minimally 14 and maximally 16. If we see the GL as the foods effect, we can assign CocaCola<sub>hardmin</sub>=14 and CocaCola<sub>hardmax</sub>=16. So, CocaCola could be a type 1 condition because it has a certain effect.
When a user adds a new food type X to the database, it can add information like carbonhydrate(%), GI and such, to help the system determine X<sub>hardmin</sub> and X<sub>hardmax</sub>.


The model tells system G<small>predicted, min</small> and G<small>predicted, max</small>


&Delta;G<sub>min</sub> = G<sub>measured</sub> - G<sub>predicted, max</sub><br/>
So, all conditions have a minimum and a maximum effect.<br/>
&Delta;G<sub>max</sub> = G<sub>measured</sub> - G<sub>predicted, min</sub><br/>
Suppose c is a condition, then:<br/>
set C contains all type 2 and 3 conditions
<math>c_{min}, c_{max} \in \mathbb{R}</math><br/>
<math>c_{min} \le c_{max}</math><br/>


If <i>C</i> contains only one condition <i>c</i>, it is quite easy for the system to directly assign &Delta;G<sub>min</sub> and &Delta;G<sub>max</sub> to <i>c</i>. The story gets less trivial when C contains multiple conditions.


Verdere notities (moeten nog verder verwerkt worden):
Also, conditions can be contained in a group (set) of conditions S:<br/>
<pre>
S = {c1, c2, ...}<br/>
Problemen bij bereken effect van conditie:
Like conditions, such group of conditions S also has minimum and maxmimum cumulative effect. Such effect is the sum of all of the effects of its contained conditions:<br/>
- Het precieze effect is onzeker. Onderzoek onderschrijft dit. Door middel van een 'range' kan wel worden
S<sub>min</sub> = c1<sub>min</sub> + c2<sub>min</sub> + ...<br/>
S<sub>max</sub> = c1<sub>max</sub> + c2<sub>max</sub> + ...<br/>


gezegt tussen welke waardes het effect waarschijnlijk ligt.
- Het leren van effecten is dus het opstellen van een 'range' waartussen een effect ligt. Hoe beter het


systeem een effect kent, hoe betrouwbaarder de gegeven range is. Uit de verschillendde gemeten 'ranges' voor
Using intuition, I came up with the following theorem. I have to give it a name so lets call it ''Kingma's Theorem'' :). It's not formally proved yet, but the following seems to be true for all cases. Its actually quite logical.<br/>
If condition c is part of set S (''and (S-c) is set S minus condition c')<br/>
and S<sub>min</sub> and S<sub>max</sub> are known<br/>
and c<sub>hardmin</sub> and c<sub>hardmax</sub> are known<br/>
then can be said:<br/>
(S-c)<sub>min</sub> = S<sub>min</sub> - c<sub>hardmax</sub><br/>
(S-c)<sub>max</sub> = S<sub>max</sub> - c<sub>hardmin</sub><br/>


een conditie wordt een range berekent die wordt gebruikt bij voorspellingen.
  Elke conditie heeft ook een harde ingebakken minimaal en maximaal effect. Je lichaam kan bijvoorbeeld


niet meer koolhydraten uit voedsel benutten dan er in zit. Het systeem kan zo'n maximum dan berekenen uit
Lets assume that at each blood glucose (BG) measurement, Cheetah starts its learning system. Cheetah looks at all conditions that could have an effect, and puts all type 1 conditions into group CE (certain effect) and all type 2 into group UE (uncertain effect).
Then, cheetah calculates the difference (min and max) between the BG<sub>measurement</sub> and predicted CE group effect. This difference should equal the UE group effect. So:<br>
BG<sub>measurement</sub> = UE<sub>real</sub> + CE<sub>real</sub><br/>
So:<br/>
UE<sub>min</sub> = BG<sub>measurement</sub> - CE<sub>max</sub><br/>
UE<sub>max</sub> = BG<sub>measurement</sub> - CE<sub>min</sub><br/>


een door de gebruiker ingevoerd aantal koolhydraten.
UE is the range of the sum of the to be learned conditions. These conditions all have their own effect range, c<sub>hardmin</sub> and c<sub>hardmax</sub>. But because the sum of effects (UE) is restricted , each individual effect for each condition must be somewhat more restricted. The possible effect range for each effect can be deduced from the total effect and the hardmin and hardmax value of the other effects. Using Kingma's Theorem, one can deduce the effect range of each individual condition.


conditietypes:
'''Example 1.1'''
1) certain conditions.
  Range is fixed
2) predicted uncertain conditions
  Range wordt berekend uit de ranges die uit het verleden geleerd worden.
3) yet unpredicted (new) conditions
  Een lege range lijst.


gevalsonderscheid dagtypes:
Lets look at a simple example of how a system would learn. Say, the user adds a glucose mearurement entry and the system starts its learning system. The user has taken a glass of applejuice A and a bread B. The user fills in a blood glucose measurement of 15.
1) - metingen zijn verklaarbaar
    dG(predicted)=MIN-MAX
    MIN<=dG(meting)<=MAX
  - condities: type 1 (certain)


2) - metingen zijn verklaarbaar
The system knows a priori (from its database):
    dG(predicted)=MIN-MAX
    MIN<=dG(meting)<=MAX
  - condities: type 1's en één type 3 (yet unpredicted, new) condition NEWCONDITION
  => RANGES(CONDITION) = (dG(meting)-MAX) - (dG(meting)-MIN)
  => Is de nieuwe range onmogelijk (buiten minimale min maximale max)?
      => Het model is onbetrouwbaar, of er mist een conditie.
        Meld gebruiker om te controleren of hij alles ingevoerd heeft.
        - als dG(meting)>MAX dan missende voedselconditie.
        - als dG(meting)<MIN dan missende insulineconditie.


3) - metingen zijn verklaarbaar
A<sub>hardmin</sub> = 2<br/>
    dG(predicted)=MIN-MAX
A<sub>hardmax</sub> = 5<br/>
    MIN<=dG(meting)<=MAX
B<sub>hardmin</sub> = 7<br/>
  - condities: type 1's en er is één type 2 (predicted uncertain) condition CONDITION(A-B)
B<sub>hardmax</sub> = 9
  => voeg de nieuwe berekende range toe aan database van de conditie:
    RANGES(CONDITION) += (dG(meting)-MAX) - (dG(meting)-MIN)
    Bereken nieuwe gemiddelde range uit deze dataset
  => Check op mogelijheid nieuwe range


4) - metingen zijn onverklaarbaar
The system calculates the effect range these two items must have had:
    dG(predicted)=MIN-MAX
    dG(meting)>MAX of dG(meting)<MIN
  - condities: type 1's
  => Het model is onbetrouwbaar, of er mist een conditie.
      Meld gebruiker om te controleren of hij alles ingevoerd heeft.
      - als dG(meting)>MAX dan missende voedselconditie.
      - als dG(meting)<MIN dan missende insulineconditie.
5) (lijkt erg op dagtype 2)
  - metingen zijn onverklaarbaar
    dG(meting)=MIN-MAX
    dG(meting)>MAX of dG(meting)<MIN
  - condities: type 1's en één type 3 (yet unpredicted, new) condition NEWCONDITION
  => RANGES(CONDITION) = (dG(meting)-MAX) - (dG(meting)-MIN)
  => Check op mogelijheid nieuwe range


UE<sub>min</sub> = BG<sub>measurement</sub> - CE<sub>max</sub> = 20 - 13 = 7<br/>
UE<sub>max</sub> = BG<sub>measurement</sub> - CE<sub>min</sub> = 20 - 9 = 11


6) - metingen zijn onverklaarbaar
Using Kingma's Theorem, The system then calculates the current A<sub>min</sub>, A<sub>max</sub>, B<sub>min</sub>, B<sub>max</sub> values:
    dG(predicted)=MIN-MAX
    dG(meting)>MAX of dG(meting)<MIN
  - condities: type 1's en er is één type 2 (predicted uncertain) condition CONDITION(A-B)
  => voeg de nieuwe berekende range toe aan database van de conditie:
    RANGES(CONDITION) += (dG(meting)-MAX) - (dG(meting)-MIN)
    Bereken nieuwe gemiddelde range uit deze dataset
  => Check op mogelijheid nieuwe range


7) -  
(UE-A)<sub>min</sub> = UE<sub>min</sub> - A<sub>hardmax</sub> = 7 - 5 = 2 (this is under B's hardmin, so) => 7<br/>
(UE-A)<sub>max</sub> = UE<sub>max</sub> - A<sub>hardmin</sub> = 11 - 2 = 9 (not above B's hardmax, so keep it)<br/>


(UE-B)<sub>min</sub> = UE<sub>min</sub> - B<sub>hardmax</sub> = 7 - 9 = -2 (this is under A's hardmin, so) => 2<br/>
(UE-B)<sub>max</sub> = UE<sub>max</sub> - B<sub>hardmin</sub> = 11 - 7 = 4 (not above A's hardmax, so keep it)<br/>


In this case, (UE-A) is B, and (UE-B) is A, is the system already calculated everything it needed:


INITIAL KNOWLEDGE BASE:
A<sub>min</sub> = (UE-B)<sub>min</sub> = 2<br/>
condities hebben een effect range (bv. een GI range),
A<sub>max</sub> = (UE-B)<sub>max</sub> = 4<br/>
met de grootse kans binnen deze range
B<sub>min</sub> = (UE-A)<sub>min</sub> = 7<br/>
APPEL(dG=3-4)
B<sub>max</sub> = (UE-A)<sub>max</sub> = 9<br/>
BROOD(dG=3-7)


DAG1:
Above values indicate the possible current effect range of A and B. The system can use this to tweak its knowledge about the overall effect range of this values. This could be done by giving a condition a list of these calculated effect ranges. An algorithm then a mean (or something) of this list to use in effect prediction.
Conditie: EET APPEL(dG=3-4)
Conditie: EET BROOD(dG=5-7)
Meting  : dG(meting)=10
LEERSYSTEEM:
1) dG(predicted)=8-11, dus dG(meting)=10 zit nog in range
  SYSTEEM VINDT NIKS ONVERKLAARBAARS


DAG2:
In other cases, when there are more then 2 conditions, the system iterates down a few levels to calculate the individual possible condition effect ranges. I will add such an example when I have time.
Conditie: EET APPEL(dG=3-4)
Meting  : dG(meting)=3
LEERSYSTEEM:
1) dG(predicted)=3-4, dus dG(meting)=3 zit nog in range
  LEERSYSTEEM VINDT NIKS NIEUWS


DAG3:
== 2. Bayesian Inference way ==
Conditie: EET APPEL(dG=3-4)
Conditie: EET VLA(dG=?-?) (NIEUWE CONDITIE, WEET EFFECT NOG NIET)
Meting  : dG(meting)=5
LEERSYSTEEM:
1) ZIET: 1 NIEUWE CONDITIE VLA(dG=?-?)
  en dG(predicted)=3+?-4+?
  en dG(meting)=5
  dus dG(onverklaarbaar)=1-2
2) KOPPELT ONVERKLAARBARE GLUCOSESTEIGING AAN DE NIEUWE CONDITIE:
  VLA(dG=1-2)


DAG4:
Lets forget the term 'condition' but the more intuitive term 'event' instead. So events are things like food intake (eg one glass of lemonade), insuline intake (one unit of type X), sports (half an hour of running), but also current health status and stress level etc. Before the system learns anything, each event is assigned an 'a priori' estimating curve, which tells us how, in time, the estimated effect on the blood glucose level 'g'. This a priori curve is  assigned before any measurements have been made (example: the a priori curve for food could be based on known carbonhydrate). Quickly said, the learning system uses the blood glucose measurements to update and improve the estimating curve.
dG(predicted)=5-10
dG(meting)=12


dus variabele condities moeten samen voor 2-7 aan variatie hebben gezorgt
Lets describe these events, their effects and their computations, in terms of a statistics problem.
stel: conditie A met hardMIN=5 en hardMAX=10
      conditie B met hardMIN=2 en hardMAX=5
dan zou conditie in zijn eentje dus als effect (min-max) dus (5-7) toevoegen      -3->+2  of -5->0
en nu komt variabele B in het spel
om het uiteindelijke effect 2-7 te behouden,
deze zou dan voor een effect (-3->+2  of -5->0) -3 tot +2 gehad kunnen hebben, dus 2-2


nu omgekeerd toekennen van waardes
=== About events ===
conditie B in zijn eentje een mogelijk effect van 2-5
Each single event <math>e_i</math> has three things.
conditie A dan een effect van 5-5 (als B=2 dan 0-5 en als B=5 dan -3 tot 2)


1) Firstly: A set of samples. Each sample is a tuple <b>(&Delta;t, &Delta;g)</b> So the set of samples could be represented on a 2-dimensional area. The sample set is initially empty, and samples are added through bayesian inference (explained below). [For extra clarity, image to be added here].


2) A prior (''a priori'') function <b>f<sub>e,prior</sub>(&Delta;t) &rarr; &Delta;g = &mu;<sub>prior</sub></b>. This is the estimated mean effect of the event, for each determined before any samples have arrived. For food, it could be determined by looking at carbonhydrate amount. For insuline, it could be determined by medicine information. If no prior function can be made, an effect is assigned a default prior function. The prior function also has a pre-determined variance &sigma;<sub>prior</sub>&sup2;. Spoken in statistic terms, the event effect at each moment in time has a normal distribution with:


andere aanpak:
<math>\sigma_e^2 = \mbox{some-static-value} \,</math><br/>
VOORBEELD 1:
<math>\mu_e = \theta \,</math>
stel: conditie A met hardMIN=5 en hardMAX=10
      conditie B met hardMIN=2 en hardMAX=5
uit meting blijkt dat variabele condities zorgen voor tussen 2-10 aan effect
STAP 1
minimaal theoretisch groepseffect is optelsom van hardMIN's (stel dit is 7)
maximaal theoretisch groepseffect is optelsom van hardMAX's (stel dit is 15)
minimaal werkelijk effect is 2
maximaal werkelijk effect is 10
minimaal mogelijk groepseffect is hoogste van de minima, dus 7
maximale mogelijk groepseffect is laagste van de maxima, dus 10
dus mogelijk groepseffect is (7-10)
STAP 2
A+B=(7-10)


hypothese 1: conditie A heeft het minimale effect, dus 5
This parameter &theta; is unknown, but it has a prior distribution with
            dan heeft conditie B een effect van 2-5 dus 2-5
hypothese 2: conditie A heeft het maximale effect, dus 10
            dan heeft conditie B een effect van -3-0 dus KAN NIET
(hypothese 3): conditie A heeft een effect van 8
            dan heeft conditie B een effect van -1-2 dus 2-2


OTEWEL:
<math>\sigma_{\theta ,prior}^2 = \mbox{some-a-priori-value} \,</math><br/>
effA + effB = 7-10 (=nieuwe kennis, evt ook voor databank)
<math>\mu_{\theta, prior} = f_{e,prior}(\triangle t) \,</math>
effA(min) = effGroep(min) - effRest(max)


minimaliseer effA(min) met maximaal haalbare effRest(max)
3) A posterior (''a posteriori'') function <b>f<sub>e,post</sub>(&Delta;t) &rarr; &Delta;g</b>. This is the esimated effect of the event after looking at the samples. It is determined as follows. The samples are divived into give time intervals, for example 15 minutes. So we have intervals t<sub>i</sub> with i=(1, ..., n), and each interval representing 15 minutes. Each of these intervals t<sub>i</sub> have a distribution &theta; with a prior distribution as explained above. The posterior distribution of t<sub>i</sub> is calculated as follows:
  effA(min) = effGroep(min) - effRest(max)
  dus
  effA(min) + effRest(max) = effGroep(min)
effA(max) = effGroep(max) - effB(min)


<math>\sigma_{\theta, post}^2=\frac{\sigma_{\theta, prior}^2\sigma_{\theta, prior}^2}{\sigma_e^2+n\sigma_{\theta, prior}^2}</math><br/>
<math>\mu_{\theta, post}=\frac{\sigma_{\theta, prior}^2\mu_{\theta, prior}+n\sigma_{\theta, prior}^2\bar x_n}{\sigma_e^2+n\sigma_{\theta, prior}^2}</math>




effA(min) = effGroep(min) - effRest(max)
To assign an evidence x<sub>i</sub> to each individual events e<sub>i</sub> you do:
als effA(min) < effA(hardmin)
-> effA(min) = effA(hardmin)
  effRest(max) | [effA=effA(min)] = effGroep(min) - effA(hardmin)


effA(max) = effGroep(max) - effGroep(min) 
<math>x_i=\mu_{prior}+a*\sigma_i^2</math><br>
als effA(max) > effA(hardmax)
-> effA(max) = effA(hardmax)
  effRest(min) | [effA=effA(max)] = effGroep(max) - effA(hardmax)


effRest(min) = effGroep(min) - effA(max)
where
als effRest(min) < effRest(min)
-> effRest(min) = effRest(hardmin)


effRest(max) = effGroep(max) - effA(min)
<math>a = \frac{x_{tot}-(\mu_1+\mu_2+...)}{\sigma_1^2+\sigma_2^2+...}</math>
als effRest(max) > effRest(hardmax)
-> effRest(max) = effRest(hardmax)
 


VOORBEELD 2:
So it comes down to some quite simple math. I'll make my explanation better when I have more time.
stel: conditie A met hardMIN=10 en hardMAX=15
      conditie B met hardMIN=2  en hardMAX=5
      conditie C met hardMIN=12 en hardMAX=17
uitmeting blijkt dat variabele condities zorgen voor tussen 30-40 aan effect
STAP1:
hardminGROEP = 24
hardmaxGROEP = 37
minWERKELIJK = 30
minWERKELIJK = 40
dus mogelijk groepseffect is (30-37)
STAP2:
=> A+B+C=(30-37)
effB+C(max) = effGroep(min) - effA(min) = 30 - 10 = 20
=> B+C=(..-20)
effB+C(min) = effGroep(max) - effA(max) = 37 - 15 = 22
=> B+C=(
 
 
effA(min) = effGroep(min) - effB(max) - effB(
 
 
Conditie: EET BROOD(G>>5)
Conditie: EET VLA(G>>5)
Meting: dG(meting)
 
 
 
 
LEERSYSTEEM REGELS:
1 NIEUWE CONDITIE A(G>>?)
ONVERKLAARBARE GLUCOSESTEIGING 'dG(onverklaarbaar)'
=>
A(dG=dG(onverklaarbaar))
 
2 NIEUWE CONDITIES A(G>>?) EN B(G>>?)
ONVERKLAARBARE GLUCOSESTEIGING 'S'
=>
B(G>>
 
 
 
 
Stel, je hebt een verzameling variabelen V
elke v
 
 
</pre>

Latest revision as of 19:00, 30 May 2006

This page reflects my idea about the Condition Effect Learning system. If you have comments, please dont delete text but add comments so I can reflect. See this as a first draft, which can be used as a basis for the Cheetah condition effect learning system.

As said in Advisory System, Cheetah needs a system that learns about the effect of certain conditions. Condtions are variables that have effect on blood glucose levels. As you can read in Advisory System, conditions can be classified as follows:

  1. Certain conditions: the effect is known and fixed. The effect is fixed, so the learning system will see the effect as certain.
  2. Uncertain conditions: the effect is not certain or not known yet. So, the effect is a prediction done by the system. The learning system tries to approve the prediction by looking at the past.

There are some complications regarding learning about condition (e.g. food) effects. Since each human and each body is different, conditions dont always have a fixed certain effect. Food for instance has a GL (Glycamic Load) that tells about the effect of the food on BG (Blood Glucose) levels. Food effect (response) varies between individuals and between days as much as 20%. Likewise, effect of insulin and activities varies between people and temporally. Therefore, to account for intra-individual and temporal differences, I think it is a good thing to generally express condition effect by a range instead of a simple number. Such a range could be a probability distribution, or expressed as (minimum,maximum) tuple. For Cheetah, 'Learning' about conditions means assigning a range or distribution to it. There are several levels of expressing such variation in terms of a range or distribution. I solved the first one, but not yet the second.

  1. Learning a condition's effect by assigning it a minimal and maximal effect value. For example, a minimum and maximum BG effect.
  2. Learning a condition's effect by seeing it as a normally distributed random variable.

1. Learning a condition's effect by assigning it a minimal and maximal effect value

With this system, all conditions X have a Xhardmin and Xhardmax variables which tells the system the hard minimum and maximum of effect. For example, research has pointed out that a can of Coca-Cola has a Glycemic Load (GL) of minimally 14 and maximally 16. If we see the GL as the foods effect, we can assign CocaColahardmin=14 and CocaColahardmax=16. So, CocaCola could be a type 1 condition because it has a certain effect. When a user adds a new food type X to the database, it can add information like carbonhydrate(%), GI and such, to help the system determine Xhardmin and Xhardmax.


So, all conditions have a minimum and a maximum effect.
Suppose c is a condition, then:
<math>c_{min}, c_{max} \in \mathbb{R}</math>
<math>c_{min} \le c_{max}</math>


Also, conditions can be contained in a group (set) of conditions S:
S = {c1, c2, ...}
Like conditions, such group of conditions S also has minimum and maxmimum cumulative effect. Such effect is the sum of all of the effects of its contained conditions:
Smin = c1min + c2min + ...
Smax = c1max + c2max + ...


Using intuition, I came up with the following theorem. I have to give it a name so lets call it Kingma's Theorem :). It's not formally proved yet, but the following seems to be true for all cases. Its actually quite logical.
If condition c is part of set S (and (S-c) is set S minus condition c')
and Smin and Smax are known
and chardmin and chardmax are known
then can be said:
(S-c)min = Smin - chardmax
(S-c)max = Smax - chardmin


Lets assume that at each blood glucose (BG) measurement, Cheetah starts its learning system. Cheetah looks at all conditions that could have an effect, and puts all type 1 conditions into group CE (certain effect) and all type 2 into group UE (uncertain effect). Then, cheetah calculates the difference (min and max) between the BGmeasurement and predicted CE group effect. This difference should equal the UE group effect. So:
BGmeasurement = UEreal + CEreal
So:
UEmin = BGmeasurement - CEmax
UEmax = BGmeasurement - CEmin

UE is the range of the sum of the to be learned conditions. These conditions all have their own effect range, chardmin and chardmax. But because the sum of effects (UE) is restricted , each individual effect for each condition must be somewhat more restricted. The possible effect range for each effect can be deduced from the total effect and the hardmin and hardmax value of the other effects. Using Kingma's Theorem, one can deduce the effect range of each individual condition.

Example 1.1

Lets look at a simple example of how a system would learn. Say, the user adds a glucose mearurement entry and the system starts its learning system. The user has taken a glass of applejuice A and a bread B. The user fills in a blood glucose measurement of 15.

The system knows a priori (from its database):

Ahardmin = 2
Ahardmax = 5
Bhardmin = 7
Bhardmax = 9

The system calculates the effect range these two items must have had:

UEmin = BGmeasurement - CEmax = 20 - 13 = 7
UEmax = BGmeasurement - CEmin = 20 - 9 = 11

Using Kingma's Theorem, The system then calculates the current Amin, Amax, Bmin, Bmax values:

(UE-A)min = UEmin - Ahardmax = 7 - 5 = 2 (this is under B's hardmin, so) => 7
(UE-A)max = UEmax - Ahardmin = 11 - 2 = 9 (not above B's hardmax, so keep it)

(UE-B)min = UEmin - Bhardmax = 7 - 9 = -2 (this is under A's hardmin, so) => 2
(UE-B)max = UEmax - Bhardmin = 11 - 7 = 4 (not above A's hardmax, so keep it)

In this case, (UE-A) is B, and (UE-B) is A, is the system already calculated everything it needed:

Amin = (UE-B)min = 2
Amax = (UE-B)max = 4
Bmin = (UE-A)min = 7
Bmax = (UE-A)max = 9

Above values indicate the possible current effect range of A and B. The system can use this to tweak its knowledge about the overall effect range of this values. This could be done by giving a condition a list of these calculated effect ranges. An algorithm then a mean (or something) of this list to use in effect prediction.

In other cases, when there are more then 2 conditions, the system iterates down a few levels to calculate the individual possible condition effect ranges. I will add such an example when I have time.

2. Bayesian Inference way

Lets forget the term 'condition' but the more intuitive term 'event' instead. So events are things like food intake (eg one glass of lemonade), insuline intake (one unit of type X), sports (half an hour of running), but also current health status and stress level etc. Before the system learns anything, each event is assigned an 'a priori' estimating curve, which tells us how, in time, the estimated effect on the blood glucose level 'g'. This a priori curve is assigned before any measurements have been made (example: the a priori curve for food could be based on known carbonhydrate). Quickly said, the learning system uses the blood glucose measurements to update and improve the estimating curve.

Lets describe these events, their effects and their computations, in terms of a statistics problem.

About events

Each single event <math>e_i</math> has three things.

1) Firstly: A set of samples. Each sample is a tuple (Δt, Δg) So the set of samples could be represented on a 2-dimensional area. The sample set is initially empty, and samples are added through bayesian inference (explained below). [For extra clarity, image to be added here].

2) A prior (a priori) function fe,prior(Δt) → Δg = μprior. This is the estimated mean effect of the event, for each determined before any samples have arrived. For food, it could be determined by looking at carbonhydrate amount. For insuline, it could be determined by medicine information. If no prior function can be made, an effect is assigned a default prior function. The prior function also has a pre-determined variance σprior². Spoken in statistic terms, the event effect at each moment in time has a normal distribution with:

<math>\sigma_e^2 = \mbox{some-static-value} \,</math>
<math>\mu_e = \theta \,</math>

This parameter θ is unknown, but it has a prior distribution with

<math>\sigma_{\theta ,prior}^2 = \mbox{some-a-priori-value} \,</math>
<math>\mu_{\theta, prior} = f_{e,prior}(\triangle t) \,</math>

3) A posterior (a posteriori) function fe,post(Δt) → Δg. This is the esimated effect of the event after looking at the samples. It is determined as follows. The samples are divived into give time intervals, for example 15 minutes. So we have intervals ti with i=(1, ..., n), and each interval representing 15 minutes. Each of these intervals ti have a distribution θ with a prior distribution as explained above. The posterior distribution of ti is calculated as follows:

<math>\sigma_{\theta, post}^2=\frac{\sigma_{\theta, prior}^2\sigma_{\theta, prior}^2}{\sigma_e^2+n\sigma_{\theta, prior}^2}</math>
<math>\mu_{\theta, post}=\frac{\sigma_{\theta, prior}^2\mu_{\theta, prior}+n\sigma_{\theta, prior}^2\bar x_n}{\sigma_e^2+n\sigma_{\theta, prior}^2}</math>


To assign an evidence xi to each individual events ei you do:

<math>x_i=\mu_{prior}+a*\sigma_i^2</math>

where

<math>a = \frac{x_{tot}-(\mu_1+\mu_2+...)}{\sigma_1^2+\sigma_2^2+...}</math>

So it comes down to some quite simple math. I'll make my explanation better when I have more time.