Good morning Simon,
Ok, that's a little bit harder but still not impossible.
Point 1: Understand the math.
This is a good link that describes the maths required: http://phoenix.phys.clemson.edu/tutorials/regression/index.html
Point 2:
The main point to remember is the dataTaker can not access historical data so you need to break it down into bits that can be calculated on the fly then calculate the final numbers when required and reset the accumulated values.
You can see from the maths we need to calculate the m value first because we need to slope to calculate the intercept.
To calculate m we need:
- The number of samples N.
- Sum of the X values.
- Sum of the Y values.
- Sum of X*Y
- Sum of (X^2)
- And (Sum X)^2
NOTE: The last two are not the same. Sum of (X^2) means take the value of X and square it. Then add it to the previous values. (Sum X)^2 means take the value of X and add it to the previous vales then, right at the end, square the lot.
To calculate the intercept (B) we need:
- The number of samples N.
- Sum of the X values.
- Sum of the Y values.
- And the M value.
So in dataTaker speak this becomes:
RA1S
1V("X",=1CV)
2V("Y",=2CV)
3CV("n")=3CV+1 'Used in M and B
4CV("Sum X")=4CV+1CV 'Used in M and B
5CV("Sum Y")=5CV+2CV 'Used in M and B
6CV("Sum X*Y")=6CV+(1CV*2CV) 'Used in M
7CV("Sum(X^2)")=7CV+1CV^2 'Used in M
RB1M
8CV("M")=(6CV-(4CV*5CV))/((3CV*4CV)-4CV^2)
9CV("B")=(5CV-(8CV*4CV))/3CV
END
Cheers,
Roger
Good morning Simon,
Ok, that's a little bit harder but still not impossible.
Point 1: Understand the math.
This is a good link that describes the maths required: http://phoenix.phys.clemson.edu/tutorials/regression/index.html
Point 2:
The main point to remember is the dataTaker can not access historical data so you need to break it down into bits that can be calculated on the fly then calculate the final numbers when required and reset the accumulated values.
You can see from the maths we need to calculate the m value first because we need to slope to calculate the intercept.
To calculate m we need:
- The number of samples N.
- Sum of the X values.
- Sum of the Y values.
- Sum of X*Y
- Sum of (X^2)
- And (Sum X)^2
NOTE: The last two are not the same. Sum of (X^2) means take the value of X and square it. Then add it to the previous values. (Sum X)^2 means take the value of X and add it to the previous vales then, right at the end, square the lot.
To calculate the intercept (B) we need:
- The number of samples N.
- Sum of the X values.
- Sum of the Y values.
- And the M value.
So in dataTaker speak this becomes:
````
RA1S
1V("X",=1CV)
2V("Y",=2CV)
3CV("n")=3CV+1 'Used in M and B
4CV("Sum X")=4CV+1CV 'Used in M and B
5CV("Sum Y")=5CV+2CV 'Used in M and B
6CV("Sum X*Y")=6CV+(1CV*2CV) 'Used in M
7CV("Sum(X^2)")=7CV+1CV^2 'Used in M
RB1M
8CV("M")=(6CV-(4CV*5CV))/((3CV*4CV)-4CV^2)
9CV("B")=(5CV-(8CV*4CV))/3CV
END
````
Cheers,
Roger