Lasersköld

2014-06-11

#teknik

Finding maximum correction for three samples

I always recalculate this when I need it, but now it is time to save it somewhere.

You have three samples y1, y2, and y3, and you want to know where the maximum is, if you do a quadratic regression from it. We assume that the distance between the points on the x-axis is 1.

graf.png

First, let's do the quadratic regression.

We describe the graph as:

y = a x2 + bx + c

So we want the values of a, b, and c.

For y2 = y(x = 0), we have:

y2 = a ·0x2 +b ·0 +c

Therefore, c = y2.

We then have that:

y1 =y(-1) =a·(-1)2) +b·(-1)+c

This simplifies to:

y1 =a-b+y2

Similarly, for y3, we have:

y3 =y(1) =a+b+y2

Now subtracting:

y3 -y1 =2b

Therefore:

b = (y3 - y1) / 2

Also, adding:

y1 +y3 =2a+2y2

Thus:

2a = y1 + y3 - 2y2

a = (y1 + y3) / 2 - y2

Now, to find the maximum, we take the derivative y':

y = a x2 + bx + c y' = 2ax +b

Setting the derivative to zero for the maximum:

0 = 2ax +b

Substitute a and b:

2 (( y1 + y3 )/ 2 - y2 ) x = -( y3 - y1 )/ 2

Solve for x:

x = ( y1 - y3 )/ ( y1 + y3 - 2 y2 )/ 2

... Done once and for all.


Andra inlägg från bloggen

2024

Använda cpp som ett skriptspråk (2024-12-03)

Mekaniskt tangentbord Lasersköld L1 del 1 (2024-11-14)

Alphasmart neo 2 font editor (2024-10-11)

Bloggen är äntligen fyttad (2024-09-24)

2022

Figurer i skuggan (2022-06-04)

2018

prestandatest pa morgonen c (2018-11-21)

2017

Framsteg och frustration (2017-08-31)

2015

fix audacity startup bug on ubuntu 1510 (2015-11-24)

git subtree (2015-06-21)

add native code to android studio (2015-06-21)

2014

Ingenting (2014-11-08)

Äldre inlägg...