Post Reply 
Small Solver Program
02-20-2019, 07:22 AM (This post was last modified: 02-20-2019 08:39 AM by Thomas Klemm.)
Post: #22
RE: Small Solver Program
(02-18-2019 10:22 PM)Thomas Klemm Wrote:  Which I still do not understand in detail.

(02-19-2019 01:10 AM)Albert Chan Wrote:  I think the code add slope data, like this:

Data points (0,90) and (30, 90.2), add to linear regression: (30+0)/2, (90.2-90)/(30-0)
Next point (60, 86.4), add to linear regression: (60+30)/2, (86.4-90.2)/(60-30)
...
N points (sorted) thus generate N-1 slopes to regress.

If we know two points \((x_1, y_1)\) and \((x_2, y_2)\) on a parabola \(y=ax^2+bx+c\) then we can calculate the slope \(y'=2ax+b\) at their midpoint \(\frac{x_1 + x_2}{2}\):

\(\begin{matrix}
y_1 = ax_1^2+bx_1+c \\
y_2 = ax_2^2+bx_2+c
\end{matrix}\)

\(\begin{align*}
y_2-y_1 &= a(x_2^2-x_1^2)+b(x_2-x_1) \\
&= a(x_2+x_1)(x_2-x_1)+b(x_2-x_1)
\end{align*}\)

\(\begin{align*}
\frac{y_2-y_1}{x_2-x_1} &= a(x_2+x_1)+b \\
&= 2a\frac{x_2+x_1}{2}+b
\end{align*}\)

This is a bit surprising since a parabola is determined by three points, but the result is independent of the third point.

With linear regression we try to minimise the distance of the vector

\(y=\begin{bmatrix}
y_1\\
\cdot\\
\cdot\\
\cdot\\
y_n
\end{bmatrix}\)

to the 3-dimensional sub-space spanned by

\(x^2=\begin{bmatrix}
x_1^2\\
\cdot\\
\cdot\\
\cdot\\
x_n^2
\end{bmatrix}\, , \,
x=\begin{bmatrix}
x_1\\
\cdot\\
\cdot\\
\cdot\\
x_n
\end{bmatrix}\, , \,
e=\begin{bmatrix}
1\\
\cdot\\
\cdot\\
\cdot\\
1
\end{bmatrix}\)

The solution is the orthogonal projection.

Now we take Csaba's transformation:

\(\Delta=
\begin{bmatrix}
-\frac{1}{x_2-x_1} & \frac{1}{x_2-x_1} & 0 & 0 & \cdots & 0 \\
0 & -\frac{1}{x_3-x_2} & \frac{1}{x_3-x_2} & 0 & \cdots & 0 \\
\cdot & \cdot & \cdot & \cdot & & \cdot \\
\cdot & \cdot & \cdot & \cdot & & \cdot \\
\cdot & \cdot & \cdot & \cdot & & \cdot \\
0 & 0 & 0 & \cdots & -\frac{1}{x_n-x_{n-1}} & \frac{1}{x_n-x_{n-1}}
\end{bmatrix}\)

and apply it to all the vectors

\(\Delta y=\begin{bmatrix}
\frac{y_2-y_1}{x_2-x1} \\
\cdot\\
\cdot\\
\cdot\\
\frac{y_n-y_{n-1}}{x_n-x_{n-1}}
\end{bmatrix}
\)

\(\Delta x^2=\begin{bmatrix}
\frac{x_2^2-x_1^2}{x_2-x1} \\
\cdot\\
\cdot\\
\cdot\\
\frac{x_n^2-x_{n-1}^2}{x_n-x_{n-1}}
\end{bmatrix}=\begin{bmatrix}
x_2+x_1\\
\cdot\\
\cdot\\
\cdot\\
x_n+x_{n-1}
\end{bmatrix}\)

\(\Delta x=\begin{bmatrix}
\frac{x_2-x_1}{x_2-x1} \\
\cdot\\
\cdot\\
\cdot\\
\frac{x_n-x_{n-1}}{x_n-x_{n-1}}
\end{bmatrix}=\begin{bmatrix}
1\\
\cdot\\
\cdot\\
\cdot\\
1
\end{bmatrix}\)

\(\Delta e=\begin{bmatrix}
0\\
\cdot\\
\cdot\\
\cdot\\
0
\end{bmatrix}\)

Since \(\Delta e = 0\) we realise that we project along the vector \(e\) into a n-1 dimensional subspace.
Here we try to minimise the distance of the vector \(\Delta y\) to the 2-dimensional sub-space spanned by \(\Delta x^2\) and \(\Delta x\).
Again the solution is the orthogonal projection.
But clearly the transformation \(\Delta\) isn't orthogonal.
Thus these two solutions aren't mapped exactly.

What reduces this error?
Csaba suggested sorting the points by their x-coordinates.
In case of his example this leads to an "isotropic" transformation \(\Delta\) since all entries of the matrix are the same except those that are 0 of course.
Is that why it works so well?
Is it enough to keep them in order, or do we also need the same distances?

I could imagine that this leads to a completely wrong result if the transformation \(\Delta\) is a distortion.

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Small Solver Program - Gamo - 02-14-2019, 05:25 AM
RE: Small Solver Program - Thomas Klemm - 02-14-2019, 07:06 AM
RE: Small Solver Program - Albert Chan - 02-15-2019, 12:07 AM
RE: Small Solver Program - Thomas Klemm - 02-15-2019, 06:26 PM
RE: Small Solver Program - Albert Chan - 02-15-2019, 09:16 PM
RE: Small Solver Program - Thomas Klemm - 02-16-2019, 03:58 AM
RE: Small Solver Program - Albert Chan - 11-03-2019, 03:14 PM
RE: Small Solver Program - Albert Chan - 11-10-2019, 07:02 PM
RE: Small Solver Program - Albert Chan - 12-01-2019, 12:13 AM
RE: Small Solver Program - Csaba Tizedes - 02-16-2019, 12:24 PM
RE: Small Solver Program - Thomas Klemm - 02-16-2019, 01:42 PM
RE: Small Solver Program - Csaba Tizedes - 02-16-2019, 03:24 PM
RE: Small Solver Program - Gamo - 02-17-2019, 02:57 AM
RE: Small Solver Program - Thomas Klemm - 02-17-2019, 09:06 AM
RE: Small Solver Program - Gamo - 02-17-2019, 02:33 PM
RE: Small Solver Program - Thomas Klemm - 02-17-2019, 04:57 PM
RE: Small Solver Program - Gamo - 02-18-2019, 03:49 AM
RE: Small Solver Program - Thomas Klemm - 02-18-2019, 05:20 AM
RE: Small Solver Program - Dieter - 02-18-2019, 07:46 PM
RE: Small Solver Program - Thomas Klemm - 02-18-2019, 10:22 PM
RE: Small Solver Program - Albert Chan - 02-19-2019, 01:10 AM
RE: Small Solver Program - Csaba Tizedes - 02-19-2019, 08:39 AM
RE: Small Solver Program - Thomas Klemm - 02-20-2019, 05:31 AM
RE: Small Solver Program - Csaba Tizedes - 02-25-2019, 08:39 PM
RE: Small Solver Program - Thomas Klemm - 02-20-2019 07:22 AM
RE: Small Solver Program - Thomas Klemm - 02-24-2019, 09:21 AM
RE: Small Solver Program - Thomas Klemm - 02-25-2019, 11:00 PM
RE: Small Solver Program - Albert Chan - 01-04-2020, 07:49 PM



User(s) browsing this thread: 1 Guest(s)