Post Reply 
Mean value by Least Squares Method
08-04-2019, 01:43 PM (This post was last modified: 08-05-2019 08:51 PM by Hans Wurst.)
Post: #5
Eureka! -- almost, only one hurdle left
(08-04-2019 09:49 AM)DrD Wrote:  Perhaps a programmable approach might be a reasonable thing to do? Especially, considering the need for capturing sample and observation data. Do you have a real-world application requiring a least square mean? [...]

Thank you for your time and the links. My goal is to derive on a HP Prime the formula of the arithmetic average aka mean value by LS method first published by Legendre and claimed by Gauss to be his idea. If you follow the a. m. link you will find "The linear least-squares problem [...] has a closed-form solution." Perhaps it would be reasonable if a programmable approach is based on an analytical solution.

If you prefere a real-world example, try this: what is the average a of x, y, and z? Use CAS of your Prime and enter \(\textbf{simplify}\! \left (\textbf{zero}\! \left ( \displaystyle \frac{\partial (x-a)^2+(y-a)^2+(a-z)^2}{\partial a}, a \right)\right)\). Result should be [(x+y+z)/3], with greetings from CG Wink

In the mean time I was not lazy and tried this and that (including RTFM) to get \(m = \displaystyle \frac{1}{n}\displaystyle\sum_{k=1}^{n}x_k\) (the well-known analytical solution) from \(\displaystyle \textbf{zero}\! \left ( \frac{\partial \displaystyle \sum_{k=1}^{n}\left ((x(k)-m)^2\right)}{\partial m}, m \right)\)
If I enter it like this, Prime tells me ["Invalid function x(k) perhaps a missing * ... blah blah"] but I do not know (and could not find an example in the manual) how to attach k as index to x (\(x_k\)) so k is still recognized by sum. Using x_k fails.
But if I enter \(\displaystyle \textbf{simplify}\! \left ( \frac{\partial \displaystyle \sum_{k=1}^{n}((x(k)-m)^2)}{\partial m} \right)\) the result is sum(2*m-2*x(k),k,1,n). Using this result and manually put it this way (and solve for m): \(\textbf{zero}\! \left ( \displaystyle 2*\sum_{k=1}^{n}(m) - 2*\sum_{k=1}^{n}(x(k)), m \right)\) Prime shows [sum(x(k),k,1,n)/n] what is exactly what I was looking for.

Now, could someone please tell me how to do it without this silly manual intermediate step?

/H.

Edit: No hint to a useful solution so far? I am surprised that a tool brimful with all kind of math, with students as intended users, may not derive easily such simple things like the arithmetic average.

Bye-bye, I'll waste my time elsewhere.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Eureka! -- almost, only one hurdle left - Hans Wurst - 08-04-2019 01:43 PM



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