Sign in

username:

password:



Not a member?

Search msp430



Search tips

Subscribe to msp430



Sponsor

controlSUITE™ software
Comprehensive.
Intuitive.
Optimized.

Real-world software for real-time control. Details Here!

Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | MSP430 | creating and solving 3rd order equations from data points


Advertise Here

The purpose of this group is to foster exchange of information on the Texas Instruments MSP430 family of microcontrollers and related tools. Everyone welcome, all levels of familiarity/expertise.

creating and solving 3rd order equations from data points - Mike - Jul 14 9:04:58 2009

Hi,

I'm looking for C-code to generate a 3rd-order equation from a set of (typically) 5 - 9 data points. For example, given x,y points:

{-.04, -.0007}
{-.03, -.0003}
{02, -0.00008}
{-.01, -0.00001}
{0, 0}
{.01, 0.00001}
{.02, 0.00007}
{.03, .0002}
{.04, .0006}

I should end up with an equation like this (so Excel tells me):

y = 10.581x^3 - 0.037x^2 - 0.0008x + 1E-06

After researching the math on the internet, my code for a 3rd order equation doesn't get anywhere close to this. Not sure if it's a bug making the linear equations from the points, or solving the equations. I trust my coding skills, but not my math... I'm using IAR's floating point lbrary (sorry Al!).

Does anyone have a routine handy that would do this? Or know of a math package that I can buy that will let me extract the C-code for just this without having to include the whole library?

Thanks,
Mike.
Kaelin Consulting
m...@kaelinconsulting.com

------------------------------------

______________________________
controlSUITE™ software. Comprehensive. Intuitive. Optimized.
Real-world software for real-time control. Details Here!



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )


Re: creating and solving 3rd order equations from data points - old_cow_yellow - Jul 14 11:06:52 2009

There are 4 coefficients in a 3rd-order equation. If you have more than 4 data points, they usually do not fit. A very common situation is, the data points have measurement errors. And you want to find the best fit to minimize the deviations from these measured data points.

The algorithm to do this was developed way before we have computers and calculators. It was used very commonly when computers and calculator were used for computing.

Look for Least Square Method.

--- In m...@yahoogroups.com, "Mike" wrote:
>
> Hi,
>
> I'm looking for C-code to generate a 3rd-order equation from a set of (typically) 5 - 9 data points. For example, given x,y points:
>
> {-.04, -.0007}
> {-.03, -.0003}
> {02, -0.00008}
> {-.01, -0.00001}
> {0, 0}
> {.01, 0.00001}
> {.02, 0.00007}
> {.03, .0002}
> {.04, .0006}
>
> I should end up with an equation like this (so Excel tells me):
>
> y = 10.581x^3 - 0.037x^2 - 0.0008x + 1E-06
>
> After researching the math on the internet, my code for a 3rd order equation doesn't get anywhere close to this. Not sure if it's a bug making the linear equations from the points, or solving the equations. I trust my coding skills, but not my math... I'm using IAR's floating point lbrary (sorry Al!).
>
> Does anyone have a routine handy that would do this? Or know of a math package that I can buy that will let me extract the C-code for just this without having to include the whole library?
>
> Thanks,
> Mike.
> Kaelin Consulting
> mike@...
>

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: creating and solving 3rd order equations from data points - Jon Kirwan - Jul 14 12:03:55 2009

On Tue, 14 Jul 2009 13:03:02 -0000, you wrote:

>I'm looking for C-code to generate a 3rd-order equation from a set of
>(typically) 5 - 9 data points. For example, given x,y points:
>
>{-.04, -.0007}
>{-.03, -.0003}
>{02, -0.00008}
>{-.01, -0.00001}
>{0, 0}
>{.01, 0.00001}
>{.02, 0.00007}
>{.03, .0002}
>{.04, .0006}
>
>I should end up with an equation like this (so Excel tells me):
>
>y = 10.581x^3 - 0.037x^2 - 0.0008x + 1E-06
>
>After researching the math on the internet, my code for a 3rd order
>equation doesn't get anywhere close to this. Not sure if it's a bug
>making the linear equations from the points, or solving the
>equations. I trust my coding skills, but not my math... I'm using
>IAR's floating point lbrary (sorry Al!).
>
>Does anyone have a routine handy that would do this? Or know of a math
>package that I can buy that will let me extract the C-code for just
>this without having to include the whole library?

I've not done this, but it would simply be a matter of setting up the
error term (probably just error^2 so that it is positive-valued, but
there are other possibilities) and the partial differential equations
and solving the simultaneous set. I haven't done it before.

The error term would be:

SUM_OVER_DATA of (Y_i - a0 - a1*X_i - a2*X_i^2 - a3*X_i^3)^2

if that makes sense to you. It's just the difference between the Y
value and the computed equation's value using X, instead. That get's
squared beforing summing them up. You will want to minimize that
error term, which is why you want to take partial derivatives of it
with respect to each of the constants, a0, a1, a2, and a3, and set
those to zero. Solving that set will give you what you need to know.

Some good numerical methods books will walk you through the process,
generally. Numerical Recipes also does this for the generalized
version of the above equation. They even include the possibility of
using known measurement errors in the computation (which weights
differently, different values, if you like.) If you don't have the
book, get it. A worked routine will be in there.

Also, I see this (have not looked it over):

http://quantlib.sourcearchive.com/documentation/0.3.13/ql_2Math_2linearleastsquaresregression_8cpp-source.html
http://quantlib.sourcearchive.com/documentation/0.3.13/ql_2Math_2linearleastsquaresregression_8hpp-source.html

This is an excellent opportunity for you to learn about this useful
and powerful technique so that it is something you own for yourself
and no one can ever take it away from you, again.

Jon
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: creating and solving 3rd order equations from data points - Henry Liu - Jul 15 21:08:15 2009

Google "least squares fit polynomial":

http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html

The algorithm is very easy to solve if your C library supplies basic
linear algebra. Otherwise it's a bunch of for loops.

On Tue, Jul 14, 2009 at 9:02 AM, Jon Kirwan wrote:
> On Tue, 14 Jul 2009 13:03:02 -0000, you wrote:
>
>>I'm looking for C-code to generate a 3rd-order equation from a set of
>>(typically) 5 - 9 data points. For example, given x,y points:
>>
>>{-.04, -.0007}
>>{-.03, -.0003}
>>{02, -0.00008}
>>{-.01, -0.00001}
>>{0, 0}
>>{.01, 0.00001}
>>{.02, 0.00007}
>>{.03, .0002}
>>{.04, .0006}
>>
>>I should end up with an equation like this (so Excel tells me):
>>
>>y = 10.581x^3 - 0.037x^2 - 0.0008x + 1E-06
>>
>>After researching the math on the internet, my code for a 3rd order
>>equation doesn't get anywhere close to this. Not sure if it's a bug
>>making the linear equations from the points, or solving the
>>equations. I trust my coding skills, but not my math... I'm using
>>IAR's floating point lbrary (sorry Al!).
>>
>>Does anyone have a routine handy that would do this? Or know of a math
>>package that I can buy that will let me extract the C-code for just
>>this without having to include the whole library?
>
> I've not done this, but it would simply be a matter of setting up the
> error term (probably just error^2 so that it is positive-valued, but
> there are other possibilities) and the partial differential equations
> and solving the simultaneous set. I haven't done it before.
>
> The error term would be:
>
> SUM_OVER_DATA of (Y_i - a0 - a1*X_i - a2*X_i^2 - a3*X_i^3)^2
>
> if that makes sense to you. It's just the difference between the Y
> value and the computed equation's value using X, instead. That get's
> squared beforing summing them up. You will want to minimize that
> error term, which is why you want to take partial derivatives of it
> with respect to each of the constants, a0, a1, a2, and a3, and set
> those to zero. Solving that set will give you what you need to know.
>
> Some good numerical methods books will walk you through the process,
> generally. Numerical Recipes also does this for the generalized
> version of the above equation. They even include the possibility of
> using known measurement errors in the computation (which weights
> differently, different values, if you like.) If you don't have the
> book, get it. A worked routine will be in there.
>
> Also, I see this (have not looked it over):
>
> http://quantlib.sourcearchive.com/documentation/0.3.13/ql_2Math_2linearleastsquaresregression_8cpp-source.html
> http://quantlib.sourcearchive.com/documentation/0.3.13/ql_2Math_2linearleastsquaresregression_8hpp-source.html
>
> This is an excellent opportunity for you to learn about this useful
> and powerful technique so that it is something you own for yourself
> and no one can ever take it away from you, again.
>
> Jon
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: creating and solving 3rd order equations from data points - Henry Liu - Jul 15 21:19:45 2009

If your math isn't so good to interpret the link I sent, here more of a hin=
t:

given n points with n>3
(x1,y1), (x2,y2), ... (xn,yn)

then find the the coefficients a0, a1, a2 such that

y=3Da0+a1*x+a2*x^2 is the equation you want

so eqn (15) of the link says:

[a0; a1; a2]=3D inv(Xt*X) * Xt * [y1; y2; ... yn]

where
X=3D[1 x1 x1^2; 1 x2 x2^2; ... 1 xn xn^2]

so just compute the transpose, matrix multiplications and the inv operation=
s.

Again very easy if you have some basic linear algebra library or time
to code it.

Henry

On Wed, Jul 15, 2009 at 6:08 PM, Henry Liu wrote:
> Google "least squares fit polynomial":
>
> http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html
>
> The algorithm is very easy to solve if your C library supplies basic
> linear algebra. =A0Otherwise it's a bunch of for loops.
>
> On Tue, Jul 14, 2009 at 9:02 AM, Jon Kirwan wro=
te:
>> On Tue, 14 Jul 2009 13:03:02 -0000, you wrote:
>>
>>>I'm looking for C-code to generate a 3rd-order equation from a set of
>>>(typically) 5 - 9 data points. For example, given x,y points:
>>>
>>>{-.04, -.0007}
>>>{-.03, -.0003}
>>>{02, -0.00008}
>>>{-.01, -0.00001}
>>>{0, 0}
>>>{.01, 0.00001}
>>>{.02, 0.00007}
>>>{.03, .0002}
>>>{.04, .0006}
>>>
>>>I should end up with an equation like this (so Excel tells me):
>>>
>>>y =3D 10.581x^3 - 0.037x^2 - 0.0008x + 1E-06
>>>
>>>After researching the math on the internet, my code for a 3rd order
>>>equation doesn't get anywhere close to this. Not sure if it's a bug
>>>making the linear equations from the points, or solving the
>>>equations. I trust my coding skills, but not my math... I'm using
>>>IAR's floating point lbrary (sorry Al!).
>>>
>>>Does anyone have a routine handy that would do this? Or know of a math
>>>package that I can buy that will let me extract the C-code for just
>>>this without having to include the whole library?
>>
>> I've not done this, but it would simply be a matter of setting up the
>> error term (probably just error^2 so that it is positive-valued, but
>> there are other possibilities) and the partial differential equations
>> and solving the simultaneous set. I haven't done it before.
>>
>> The error term would be:
>>
>> SUM_OVER_DATA of (Y_i - a0 - a1*X_i - a2*X_i^2 - a3*X_i^3)^2
>>
>> if that makes sense to you. It's just the difference between the Y
>> value and the computed equation's value using X, instead. That get's
>> squared beforing summing them up. You will want to minimize that
>> error term, which is why you want to take partial derivatives of it
>> with respect to each of the constants, a0, a1, a2, and a3, and set
>> those to zero. Solving that set will give you what you need to know.
>>
>> Some good numerical methods books will walk you through the process,
>> generally. Numerical Recipes also does this for the generalized
>> version of the above equation. They even include the possibility of
>> using known measurement errors in the computation (which weights
>> differently, different values, if you like.) If you don't have the
>> book, get it. A worked routine will be in there.
>>
>> Also, I see this (have not looked it over):
>>
>> http://quantlib.sourcearchive.com/documentation/0.3.13/ql_2Math_2linearl=
eastsquaresregression_8cpp-source.html
>> http://quantlib.sourcearchive.com/documentation/0.3.13/ql_2Math_2linearl=
eastsquaresregression_8hpp-source.html
>>
>> This is an excellent opportunity for you to learn about this useful
>> and powerful technique so that it is something you own for yourself
>> and no one can ever take it away from you, again.
>>
>> Jon
>>
>>=20
>
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: creating and solving 3rd order equations from data points - Jon Kirwan - Jul 15 22:46:28 2009

On Wed, 15 Jul 2009 18:08:01 -0700, you wrote:

>Google "least squares fit polynomial":
>
>http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html
>
>The algorithm is very easy to solve if your C library supplies basic
>linear algebra. Otherwise it's a bunch of for loops.

Henry, if you are helping the OP, fine. But it may be a little
confusing to reply to me, if that is the case. It sounds like you are
trying to help the wrong person the way you wrote your reply. I don't
need it as I can easily do the partials by myself and solve the
resulting set. (And I've coded my own command line linear solver
whenever the need arises for that.)

Jon
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

RE: creating and solving 3rd order equations from data points - Microbit_P43000 - Jul 16 0:50:37 2009

> y=3Da0+a1*x+a2*x^2 is the equation you want

I don't get this...
An equation like that :
ax^2 + bx + c
produces a parabolic plot.
So how can that fit into only a few data points ?
Or is the inverse method, using just a few data points as input just a roug=
h approximation
?

Best Regards,
Kris=20

> -----Original Message-----
> From: m...@yahoogroups.com [mailto:m...@yahoogroups.com] On Behalf Of=
Henry Liu
> Sent: Thursday, 16 July 2009 11:18 AM
> To: m...@yahoogroups.com
> Subject: Re: [msp430] creating and solving 3rd order equations from data =
points
>=20
> If your math isn't so good to interpret the link I sent, here more of a h=
int:
>=20
> given n points with n>3
> (x1,y1), (x2,y2), ... (xn,yn)
>=20
> then find the the coefficients a0, a1, a2 such that
>=20
> y=3Da0+a1*x+a2*x^2 is the equation you want
>=20
> so eqn (15) of the link says:
>=20
> [a0; a1; a2]=3D inv(Xt*X) * Xt * [y1; y2; ... yn]
>=20
> where
> X=3D[1 x1 x1^2; 1 x2 x2^2; ... 1 xn xn^2]
>=20
> so just compute the transpose, matrix multiplications and the inv operati=
ons.
>=20
> Again very easy if you have some basic linear algebra library or time
> to code it.
>=20
> Henry
>=20
> On Wed, Jul 15, 2009 at 6:08 PM, Henry Liu wrote:
> > Google "least squares fit polynomial":
> >
> > http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html
> >
> > The algorithm is very easy to solve if your C library supplies basic
> > linear algebra. =A0Otherwise it's a bunch of for loops.
> >
> > On Tue, Jul 14, 2009 at 9:02 AM, Jon Kirwan w=
rote:
> >>
> >>
> >> On Tue, 14 Jul 2009 13:03:02 -0000, you wrote:
> >>
> >>>I'm looking for C-code to generate a 3rd-order equation from a set of
> >>>(typically) 5 - 9 data points. For example, given x,y points:
> >>>
> >>>{-.04, -.0007}
> >>>{-.03, -.0003}
> >>>{02, -0.00008}
> >>>{-.01, -0.00001}
> >>>{0, 0}
> >>>{.01, 0.00001}
> >>>{.02, 0.00007}
> >>>{.03, .0002}
> >>>{.04, .0006}
> >>>
> >>>I should end up with an equation like this (so Excel tells me):
> >>>
> >>>y =3D 10.581x^3 - 0.037x^2 - 0.0008x + 1E-06
> >>>
> >>>After researching the math on the internet, my code for a 3rd order
> >>>equation doesn't get anywhere close to this. Not sure if it's a bug
> >>>making the linear equations from the points, or solving the
> >>>equations. I trust my coding skills, but not my math... I'm using
> >>>IAR's floating point lbrary (sorry Al!).
> >>>
> >>>Does anyone have a routine handy that would do this? Or know of a math
> >>>package that I can buy that will let me extract the C-code for just
> >>>this without having to include the whole library?
> >>
> >> I've not done this, but it would simply be a matter of setting up the
> >> error term (probably just error^2 so that it is positive-valued, but
> >> there are other possibilities) and the partial differential equations
> >> and solving the simultaneous set. I haven't done it before.
> >>
> >> The error term would be:
> >>
> >> SUM_OVER_DATA of (Y_i - a0 - a1*X_i - a2*X_i^2 - a3*X_i^3)^2
> >>
> >> if that makes sense to you. It's just the difference between the Y
> >> value and the computed equation's value using X, instead. That get's
> >> squared beforing summing them up. You will want to minimize that
> >> error term, which is why you want to take partial derivatives of it
> >> with respect to each of the constants, a0, a1, a2, and a3, and set
> >> those to zero. Solving that set will give you what you need to know.
> >>
> >> Some good numerical methods books will walk you through the process,
> >> generally. Numerical Recipes also does this for the generalized
> >> version of the above equation. They even include the possibility of
> >> using known measurement errors in the computation (which weights
> >> differently, different values, if you like.) If you don't have the
> >> book, get it. A worked routine will be in there.
> >>
> >> Also, I see this (have not looked it over):
> >>
> >http://quantlib.sourcearchive.com/documentation/0.3.13/ql_2Math_2linearleas=
tsquaresregress
ion_8
> cpp-source.html
> >http://quantlib.sourcearchive.com/documentation/0.3.13/ql_2Math_2linearleas=
tsquaresregress
ion_8
> hpp-source.html
> >>
> >> This is an excellent opportunity for you to learn about this useful
> >> and powerful technique so that it is something you own for yourself
> >> and no one can ever take it away from you, again.
> >>
> >> Jon
> >>
> >>
> >
>=20
>=20
> ------------------------------------
>=20
>
>=20
>



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: creating and solving 3rd order equations from data points - old_cow_yellow - Jul 16 1:21:44 2009

Least Square Method is commonly used in Regression Analysis.=20
Perhaps we regressed ;-)

--- In m...@yahoogroups.com, "Microbit_P43000" wrote:
>
> > y=3Da0+a1*x+a2*x^2 is the equation you want
>=20
> I don't get this...
> An equation like that :
> ax^2 + bx + c
> produces a parabolic plot.
> So how can that fit into only a few data points ?
> Or is the inverse method, using just a few data points as input just a ro=
ugh approximation
> ?
>=20
> Best Regards,
> Kris=20
>=20
> > -----Original Message-----
> > From: m...@yahoogroups.com [mailto:m...@yahoogroups.com] On Behalf =
Of Henry Liu
> > Sent: Thursday, 16 July 2009 11:18 AM
> > To: m...@yahoogroups.com
> > Subject: Re: [msp430] creating and solving 3rd order equations from dat=
a points
> >=20
> > If your math isn't so good to interpret the link I sent, here more of a=
hint:
> >=20
> > given n points with n>3
> > (x1,y1), (x2,y2), ... (xn,yn)
> >=20
> > then find the the coefficients a0, a1, a2 such that
> >=20
> > y=3Da0+a1*x+a2*x^2 is the equation you want
> >=20
> > so eqn (15) of the link says:
> >=20
> > [a0; a1; a2]=3D inv(Xt*X) * Xt * [y1; y2; ... yn]
> >=20
> > where
> > X=3D[1 x1 x1^2; 1 x2 x2^2; ... 1 xn xn^2]
> >=20
> > so just compute the transpose, matrix multiplications and the inv opera=
tions.
> >=20
> > Again very easy if you have some basic linear algebra library or time
> > to code it.
> >=20
> > Henry
> >=20
> > On Wed, Jul 15, 2009 at 6:08 PM, Henry Liu wrote:
> > > Google "least squares fit polynomial":
> > >
> > > http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html
> > >
> > > The algorithm is very easy to solve if your C library supplies basic
> > > linear algebra. =A0Otherwise it's a bunch of for loops.
> > >
> > > On Tue, Jul 14, 2009 at 9:02 AM, Jon Kirwan wrote:
> > >>
> > >>
> > >> On Tue, 14 Jul 2009 13:03:02 -0000, you wrote:
> > >>
> > >>>I'm looking for C-code to generate a 3rd-order equation from a set o=
f
> > >>>(typically) 5 - 9 data points. For example, given x,y points:
> > >>>
> > >>>{-.04, -.0007}
> > >>>{-.03, -.0003}
> > >>>{02, -0.00008}
> > >>>{-.01, -0.00001}
> > >>>{0, 0}
> > >>>{.01, 0.00001}
> > >>>{.02, 0.00007}
> > >>>{.03, .0002}
> > >>>{.04, .0006}
> > >>>
> > >>>I should end up with an equation like this (so Excel tells me):
> > >>>
> > >>>y =3D 10.581x^3 - 0.037x^2 - 0.0008x + 1E-06
> > >>>
> > >>>After researching the math on the internet, my code for a 3rd order
> > >>>equation doesn't get anywhere close to this. Not sure if it's a bug
> > >>>making the linear equations from the points, or solving the
> > >>>equations. I trust my coding skills, but not my math... I'm using
> > >>>IAR's floating point lbrary (sorry Al!).
> > >>>
> > >>>Does anyone have a routine handy that would do this? Or know of a ma=
th
> > >>>package that I can buy that will let me extract the C-code for just
> > >>>this without having to include the whole library?
> > >>
> > >> I've not done this, but it would simply be a matter of setting up th=
e
> > >> error term (probably just error^2 so that it is positive-valued, but
> > >> there are other possibilities) and the partial differential equation=
s
> > >> and solving the simultaneous set. I haven't done it before.
> > >>
> > >> The error term would be:
> > >>
> > >> SUM_OVER_DATA of (Y_i - a0 - a1*X_i - a2*X_i^2 - a3*X_i^3)^2
> > >>
> > >> if that makes sense to you. It's just the difference between the Y
> > >> value and the computed equation's value using X, instead. That get's
> > >> squared beforing summing them up. You will want to minimize that
> > >> error term, which is why you want to take partial derivatives of it
> > >> with respect to each of the constants, a0, a1, a2, and a3, and set
> > >> those to zero. Solving that set will give you what you need to know.
> > >>
> > >> Some good numerical methods books will walk you through the process,
> > >> generally. Numerical Recipes also does this for the generalized
> > >> version of the above equation. They even include the possibility of
> > >> using known measurement errors in the computation (which weights
> > >> differently, different values, if you like.) If you don't have the
> > >> book, get it. A worked routine will be in there.
> > >>
> > >> Also, I see this (have not looked it over):
> > >>
> > >>
> >
> http://quantlib.sourcearchive.com/documentation/0.3.13/ql_2Math_2linearle=
astsquaresregress
> ion_8
> > cpp-source.html
> > >>
> >
> http://quantlib.sourcearchive.com/documentation/0.3.13/ql_2Math_2linearle=
astsquaresregress
> ion_8
> > hpp-source.html
> > >>
> > >> This is an excellent opportunity for you to learn about this useful
> > >> and powerful technique so that it is something you own for yourself
> > >> and no one can ever take it away from you, again.
> > >>
> > >> Jon
> > >>
> > >>
> > >
> >=20
> >=20
> > ------------------------------------
> >=20
> >
> >=20
> >



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: creating and solving 3rd order equations from data points - Mike - Jul 16 11:47:15 2009


Hi Henry,=20

I saw the website you listed, plus several others... Let me walk through th=
is to verify my thinking...=20

For linear regression, as I understand it, the matrix looks like this:

[
n sum(x) sum(x^2) sum(x^3) -sum(y)

sum(x) sum(x^2) sum(x^3) sum(x^4) -sum(x)sum(y)

sum(x^2) sum(x^3) sum(x^4) sum(x^5) -sum(x^2)sum(y)

sum(x^3) sum(x^4) sum(x^5) sum(x^6) -sum(x^3)sum(y)
]

Where n is the number of points, sum(x) is the sum of all x coordinates, su=
m(x^2) is the sum of all x coordinates squared, etc.=20

Using Gaussian elimination (again, as I understand it), the matrix I end up=
after reduction looks like this:

1 0 0 0 A
0 1 0 0 B
0 0 1 0 C
0 0 0 1 D

Meaning that y =3D Ax + Bx^2 + Cx^3 + D

As I said in the previous post, A,B,C,D don't look anything like what I get=
out of Excel. Unfortunately, Excel doesn't give me intermediate results so=
that I can verify my equations. If you see a problem with my math or logic=
, I can start there... Otherwise I can look at the mechanics of my C-code f=
or an error. I appreciate your help!

Thanks,
Mike.

--- In m...@yahoogroups.com, Henry Liu wrote:
>
> If your math isn't so good to interpret the link I sent, here more of a h=
int:
>=20
> given n points with n>3
> (x1,y1), (x2,y2), ... (xn,yn)
>=20
> then find the the coefficients a0, a1, a2 such that
>=20
> y=3Da0+a1*x+a2*x^2 is the equation you want
>=20
> so eqn (15) of the link says:
>=20
> [a0; a1; a2]=3D inv(Xt*X) * Xt * [y1; y2; ... yn]
>=20
> where
> X=3D[1 x1 x1^2; 1 x2 x2^2; ... 1 xn xn^2]
>=20
> so just compute the transpose, matrix multiplications and the inv operati=
ons.
>=20
> Again very easy if you have some basic linear algebra library or time
> to code it.
>=20
> Henry
>=20
> On Wed, Jul 15, 2009 at 6:08 PM, Henry Liu wrote:
> > Google "least squares fit polynomial":
> >
> > http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html
> >
> > The algorithm is very easy to solve if your C library supplies basic
> > linear algebra. =A0Otherwise it's a bunch of for loops.
> >
> > On Tue, Jul 14, 2009 at 9:02 AM, Jon Kirwan wrote:
> >>
> >>
> >> On Tue, 14 Jul 2009 13:03:02 -0000, you wrote:
> >>
> >>>I'm looking for C-code to generate a 3rd-order equation from a set of
> >>>(typically) 5 - 9 data points. For example, given x,y points:
> >>>
> >>>{-.04, -.0007}
> >>>{-.03, -.0003}
> >>>{02, -0.00008}
> >>>{-.01, -0.00001}
> >>>{0, 0}
> >>>{.01, 0.00001}
> >>>{.02, 0.00007}
> >>>{.03, .0002}
> >>>{.04, .0006}
> >>>
> >>>I should end up with an equation like this (so Excel tells me):
> >>>
> >>>y =3D 10.581x^3 - 0.037x^2 - 0.0008x + 1E-06
> >>>
> >>>After researching the math on the internet, my code for a 3rd order
> >>>equation doesn't get anywhere close to this. Not sure if it's a bug
> >>>making the linear equations from the points, or solving the
> >>>equations. I trust my coding skills, but not my math... I'm using
> >>>IAR's floating point lbrary (sorry Al!).
> >>>
> >>>Does anyone have a routine handy that would do this? Or know of a math
> >>>package that I can buy that will let me extract the C-code for just
> >>>this without having to include the whole library?
> >>

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: creating and solving 3rd order equations from data points - Henry Liu - Jul 16 12:29:30 2009

Sorry for third order it's ax^3+bx^2+cx+d

Easy enough change

On Wed, Jul 15, 2009 at 9:48 PM,
Microbit_P43000 wrote:
>> y=3Da0+a1*x+a2*x^2 is the equation you want
>
> I don't get this...
> An equation like that :
> ax^2 + bx + c
> produces a parabolic plot.
> So how can that fit into only a few data points ?
> Or is the inverse method, using just a few data points as input just a ro=
ugh
> approximation
> ?
>
> Best Regards,
> Kris
>
>> -----Original Message-----
>> From: m...@yahoogroups.com [mailto:m...@yahoogroups.com] On Behalf O=
f
>> Henry Liu
>> Sent: Thursday, 16 July 2009 11:18 AM
>> To: m...@yahoogroups.com
>> Subject: Re: [msp430] creating and solving 3rd order equations from data
>> points
>>
>> If your math isn't so good to interpret the link I sent, here more of a
>> hint:
>>
>> given n points with n>3
>> (x1,y1), (x2,y2), ... (xn,yn)
>>
>> then find the the coefficients a0, a1, a2 such that
>>
>> y=3Da0+a1*x+a2*x^2 is the equation you want
>>
>> so eqn (15) of the link says:
>>
>> [a0; a1; a2]=3D inv(Xt*X) * Xt * [y1; y2; ... yn]
>>
>> where
>> X=3D[1 x1 x1^2; 1 x2 x2^2; ... 1 xn xn^2]
>>
>> so just compute the transpose, matrix multiplications and the inv
>> operations.
>>
>> Again very easy if you have some basic linear algebra library or time
>> to code it.
>>
>> Henry
>>
>> On Wed, Jul 15, 2009 at 6:08 PM, Henry Liu wrote:
>> > Google "least squares fit polynomial":
>> >
>> > http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html
>> >
>> > The algorithm is very easy to solve if your C library supplies basic
>> > linear algebra. =A0Otherwise it's a bunch of for loops.
>> >
>> > On Tue, Jul 14, 2009 at 9:02 AM, Jon Kirwan
>> > wrote:
>> >>
>> >>
>> >> On Tue, 14 Jul 2009 13:03:02 -0000, you wrote:
>> >>
>> >>>I'm looking for C-code to generate a 3rd-order equation from a set of
>> >>>(typically) 5 - 9 data points. For example, given x,y points:
>> >>>
>> >>>{-.04, -.0007}
>> >>>{-.03, -.0003}
>> >>>{02, -0.00008}
>> >>>{-.01, -0.00001}
>> >>>{0, 0}
>> >>>{.01, 0.00001}
>> >>>{.02, 0.00007}
>> >>>{.03, .0002}
>> >>>{.04, .0006}
>> >>>
>> >>>I should end up with an equation like this (so Excel tells me):
>> >>>
>> >>>y =3D 10.581x^3 - 0.037x^2 - 0.0008x + 1E-06
>> >>>
>> >>>After researching the math on the internet, my code for a 3rd order
>> >>>equation doesn't get anywhere close to this. Not sure if it's a bug
>> >>>making the linear equations from the points, or solving the
>> >>>equations. I trust my coding skills, but not my math... I'm using
>> >>>IAR's floating point lbrary (sorry Al!).
>> >>>
>> >>>Does anyone have a routine handy that would do this? Or know of a mat=
h
>> >>>package that I can buy that will let me extract the C-code for just
>> >>>this without having to include the whole library?
>> >>
>> >> I've not done this, but it would simply be a matter of setting up the
>> >> error term (probably just error^2 so that it is positive-valued, but
>> >> there are other possibilities) and the partial differential equations
>> >> and solving the simultaneous set. I haven't done it before.
>> >>
>> >> The error term would be:
>> >>
>> >> SUM_OVER_DATA of (Y_i - a0 - a1*X_i - a2*X_i^2 - a3*X_i^3)^2
>> >>
>> >> if that makes sense to you. It's just the difference between the Y
>> >> value and the computed equation's value using X, instead. That get's
>> >> squared beforing summing them up. You will want to minimize that
>> >> error term, which is why you want to take partial derivatives of it
>> >> with respect to each of the constants, a0, a1, a2, and a3, and set
>> >> those to zero. Solving that set will give you what you need to know.
>> >>
>> >> Some good numerical methods books will walk you through the process,
>> >> generally. Numerical Recipes also does this for the generalized
>> >> version of the above equation. They even include the possibility of
>> >> using known measurement errors in the computation (which weights
>> >> differently, different values, if you like.) If you don't have the
>> >> book, get it. A worked routine will be in there.
>> >>
>> >> Also, I see this (have not looked it over):
>> >>
>> > http://quantlib.sourcearchive.com/documentation/0.3.13/ql_2Math_2linearle=
astsquaresregress
> ion_8
>> cpp-source.html
>> > http://quantlib.sourcearchive.com/documentation/0.3.13/ql_2Math_2linearle=
astsquaresregress
> ion_8
>> hpp-source.html
>> >>
>> >> This is an excellent opportunity for you to learn about this useful
>> >> and powerful technique so that it is something you own for yourself
>> >> and no one can ever take it away from you, again.
>> >>
>> >> Jon
>> >>
>> >>
>> >
>> ------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Re: creating and solving 3rd order equations from data points - Henry Liu - Jul 16 12:44:32 2009

I think you flipped a minus sign:

http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html

eqn 9 is equiv to running Guass jordan elimination on:

[
n sum(x) sum(x^2) sum(x^3) sum(y)

sum(x) sum(x^2) sum(x^3) sum(x^4) sum(x)sum(y)

sum(x^2) sum(x^3) sum(x^4) sum(x^5) sum(x^2)sum(y)

sum(x^3) sum(x^4) sum(x^5) sum(x^6) sum(x^3)sum(y)
]

On Thu, Jul 16, 2009 at 8:46 AM, Mike wrote:
> Hi Henry,
>
> I saw the website you listed, plus several others... Let me walk through
> this to verify my thinking...
>
> For linear regression, as I understand it, the matrix looks like this:
>
> [
> n sum(x) sum(x^2) sum(x^3) -sum(y)
>
> sum(x) sum(x^2) sum(x^3) sum(x^4) -sum(x)sum(y)
>
> sum(x^2) sum(x^3) sum(x^4) sum(x^5) -sum(x^2)sum(y)
>
> sum(x^3) sum(x^4) sum(x^5) sum(x^6) -sum(x^3)sum(y)
> ]
>
> Where n is the number of points, sum(x) is the sum of all x coordinates,
> sum(x^2) is the sum of all x coordinates squared, etc.
>
> Using Gaussian elimination (again, as I understand it), the matrix I end =
up
> after reduction looks like this:
>
> 1 0 0 0 A
> 0 1 0 0 B
> 0 0 1 0 C
> 0 0 0 1 D
>
> Meaning that y =3D Ax + Bx^2 + Cx^3 + D
>
> As I said in the previous post, A,B,C,D don't look anything like what I g=
et
> out of Excel. Unfortunately, Excel doesn't give me intermediate results s=
o
> that I can verify my equations. If you see a problem with my math or logi=
c,
> I can start there... Otherwise I can look at the mechanics of my C-code f=
or
> an error. I appreciate your help!
>
> Thanks,
> Mike.
>
> --- In m...@yahoogroups.com, Henry Liu wrote:
>>
>> If your math isn't so good to interpret the link I sent, here more of a
>> hint:
>>
>> given n points with n>3
>> (x1,y1), (x2,y2), ... (xn,yn)
>>
>> then find the the coefficients a0, a1, a2 such that
>>
>> y=3Da0+a1*x+a2*x^2 is the equation you want
>>
>> so eqn (15) of the link says:
>>
>> [a0; a1; a2]=3D inv(Xt*X) * Xt * [y1; y2; ... yn]
>>
>> where
>> X=3D[1 x1 x1^2; 1 x2 x2^2; ... 1 xn xn^2]
>>
>> so just compute the transpose, matrix multiplications and the inv
>> operations.
>>
>> Again very easy if you have some basic linear algebra library or time
>> to code it.
>>
>> Henry
>>
>> On Wed, Jul 15, 2009 at 6:08 PM, Henry Liu wrote:
>> > Google "least squares fit polynomial":
>> >
>> > http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html
>> >
>> > The algorithm is very easy to solve if your C library supplies basic
>> > linear algebra. =A0Otherwise it's a bunch of for loops.
>> >
>> > On Tue, Jul 14, 2009 at 9:02 AM, Jon Kirwan wrote:
>> >>
>> >>
>> >> On Tue, 14 Jul 2009 13:03:02 -0000, you wrote:
>> >>
>> >>>I'm looking for C-code to generate a 3rd-order equation from a set of
>> >>>(typically) 5 - 9 data points. For example, given x,y points:
>> >>>
>> >>>{-.04, -.0007}
>> >>>{-.03, -.0003}
>> >>>{02, -0.00008}
>> >>>{-.01, -0.00001}
>> >>>{0, 0}
>> >>>{.01, 0.00001}
>> >>>{.02, 0.00007}
>> >>>{.03, .0002}
>> >>>{.04, .0006}
>> >>>
>> >>>I should end up with an equation like this (so Excel tells me):
>> >>>
>> >>>y =3D 10.581x^3 - 0.037x^2 - 0.0008x + 1E-06
>> >>>
>> >>>After researching the math on the internet, my code for a 3rd order
>> >>>equation doesn't get anywhere close to this. Not sure if it's a bug
>> >>>making the linear equations from the points, or solving the
>> >>>equations. I trust my coding skills, but not my math... I'm using
>> >>>IAR's floating point lbrary (sorry Al!).
>> >>>
>> >>>Does anyone have a routine handy that would do this? Or know of a mat=
h
>> >>>package that I can buy that will let me extract the C-code for just
>> >>>this without having to include the whole library?
>> >>=20
------------------------------------

______________________________
controlSUITE™ software. Comprehensive. Intuitive. Optimized.
Real-world software for real-time control. Details Here!



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Re: creating and solving 3rd order equations from data points - Jon Kirwan - Jul 17 7:20:02 2009

On Thu, 16 Jul 2009 09:43:38 -0700, Henry Liu wrote:
>
>On Thu, Jul 16, 2009 at 8:46 AM, Mike wrote:
>>
>> Hi Henry,
>>
>> I saw the website you listed, plus several others... Let me walk through
>> this to verify my thinking...
>>
>> For linear regression, as I understand it, the matrix looks like this:
>>
>> [
>> n sum(x) sum(x^2) sum(x^3) -sum(y)
>> sum(x) sum(x^2) sum(x^3) sum(x^4) -sum(x)sum(y)
>> sum(x^2) sum(x^3) sum(x^4) sum(x^5) -sum(x^2)sum(y)
>> sum(x^3) sum(x^4) sum(x^5) sum(x^6) -sum(x^3)sum(y)
>> ]
>>
>
>>
>> Thanks,
>> Mike.
>>
>I think you flipped a minus sign:
>
>http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html
>
>eqn 9 is equiv to running Guass jordan elimination on:
>
>[
>n sum(x) sum(x^2) sum(x^3) sum(y)
>sum(x) sum(x^2) sum(x^3) sum(x^4) sum(x)sum(y)
>sum(x^2) sum(x^3) sum(x^4) sum(x^5) sum(x^2)sum(y)
>sum(x^3) sum(x^4) sum(x^5) sum(x^6) sum(x^3)sum(y)
>]

Has everyone somehow forgotten how to read bog-standard summation
notation?? The above examples, both the one from Mike interpreting
the offered web page __and__ the 'corrected' one from Henry somehow
managed to each fail to read the web page accurately.

Take a look at the right column vector on the web page for equation 9
(or 12, I suppose.) A close look. See if you can spot the problem
between the above transliterations and the original work on the web
page.

Jon
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Re: creating and solving 3rd order equations from data points - Henry Liu - Jul 17 12:04:53 2009

Ya the RHS should be:
sum(yi)
sum(xi*yi)
...sum(x^3*y)

I always knew a PhD from Stanford and math minor would teach me something.

On Fri, Jul 17, 2009 at 4:19 AM, Jon Kirwan wrote:
> On Thu, 16 Jul 2009 09:43:38 -0700, Henry Liu wrote:
>>
>>On Thu, Jul 16, 2009 at 8:46 AM, Mike wrote:
>>>
>>> Hi Henry,
>>>
>>> I saw the website you listed, plus several others... Let me walk through
>>> this to verify my thinking...
>>>
>>> For linear regression, as I understand it, the matrix looks like this:
>>>
>>> [
>>> n sum(x) sum(x^2) sum(x^3) -sum(y)
>>> sum(x) sum(x^2) sum(x^3) sum(x^4) -sum(x)sum(y)
>>> sum(x^2) sum(x^3) sum(x^4) sum(x^5) -sum(x^2)sum(y)
>>> sum(x^3) sum(x^4) sum(x^5) sum(x^6) -sum(x^3)sum(y)
>>> ]
>>>
>>
>>>
>>> Thanks,
>>> Mike.
>>>
>>I think you flipped a minus sign:
>>
>>http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html
>>
>>eqn 9 is equiv to running Guass jordan elimination on:
>>
>>[
>>n sum(x) sum(x^2) sum(x^3) sum(y)
>>sum(x) sum(x^2) sum(x^3) sum(x^4) sum(x)sum(y)
>>sum(x^2) sum(x^3) sum(x^4) sum(x^5) sum(x^2)sum(y)
>>sum(x^3) sum(x^4) sum(x^5) sum(x^6) sum(x^3)sum(y)
>>]
>
> Has everyone somehow forgotten how to read bog-standard summation
> notation?? The above examples, both the one from Mike interpreting
> the offered web page __and__ the 'corrected' one from Henry somehow
> managed to each fail to read the web page accurately.
>
> Take a look at the right column vector on the web page for equation 9
> (or 12, I suppose.) A close look. See if you can spot the problem
> between the above transliterations and the original work on the web
> page.
>
> Jon
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Re: creating and solving 3rd order equations from data points - Jon Kirwan - Jul 17 14:19:56 2009

On Fri, 17 Jul 2009 09:03:45 -0700, Henry wrote:

>Ya the RHS should be:
>sum(yi)
>sum(xi*yi)
>...sum(x^3*y)

Beautiful!

>I always knew a PhD from Stanford and math minor would teach me something.

:)

.....

Now, if someone actually _wants_ C code to do this, I recommend they
look up "LDLT decomposition" (the starting matrix is symmetric, but I
don't think Cholesky would always work since the general case here
isn't necessarily also "positive definite.") The more general LU
decomp could also be used (and where it may be easier to find a good,
well worked algorithm.) I can provide LU decomp code I've written in
c, if desired. (It handles the general case of NxN right now, but it
could easily be recoded for a fixed 4x4 situation.) I don't have
handy my own version of LDLT, though.

Jon
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Re: creating and solving 3rd order equations from data points - Henry Liu - Jul 17 15:00:50 2009

Well At*A is always positive semidefinite and there are several
efficient Cholesky least squares algorithms. Why bother using LU when
you only want to solve the equation for 1 set of results? If I
remember correctly, Ax=b decomposed into LUx=b so that Ly=b solve for
y and Ux=y for x seems to have uses only if we are solving for
multiple b.

Not only that but in the 3rd order polynomial fit it's only a 4x4
matrix so I wouldn't even bother thinking about it.

Numerical recipes and lapack both have very efficient implementations
but sounds like the OP already has a way to solve the matrix once it
was formed.

But why reinvent the wheel? I'm sure you can find a lsq fit or at
least a linear equation solver for the msp430 in C or even in ASM.

Henry

On Fri, Jul 17, 2009 at 11:19 AM, Jon Kirwan wrote:
> On Fri, 17 Jul 2009 09:03:45 -0700, Henry wrote:
>
>>Ya the RHS should be:
>>sum(yi)
>>sum(xi*yi)
>>...sum(x^3*y)
>
> Beautiful!
>
>>I always knew a PhD from Stanford and math minor would teach me something.
>
> :)
>
> .....
>
> Now, if someone actually _wants_ C code to do this, I recommend they
> look up "LDLT decomposition" (the starting matrix is symmetric, but I
> don't think Cholesky would always work since the general case here
> isn't necessarily also "positive definite.") The more general LU
> decomp could also be used (and where it may be easier to find a good,
> well worked algorithm.) I can provide LU decomp code I've written in
> c, if desired. (It handles the general case of NxN right now, but it
> could easily be recoded for a fixed 4x4 situation.) I don't have
> handy my own version of LDLT, though.
>
> Jon
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Re: creating and solving 3rd order equations from data points - Jon Kirwan - Jul 17 15:19:30 2009

On Fri, 17 Jul 2009 11:59:36 -0700, Henry wrote:

>Well At*A is always positive semidefinite and there are several
>efficient Cholesky least squares algorithms. Why bother using LU when
>you only want to solve the equation for 1 set of results? If I
>remember correctly, Ax=b decomposed into LUx=b so that Ly=b solve for
>y and Ux=y for x seems to have uses only if we are solving for
>multiple b.
>
>Not only that but in the 3rd order polynomial fit it's only a 4x4
>matrix so I wouldn't even bother thinking about it.

hehe. Agreed.

>Numerical recipes and lapack both have very efficient implementations
>but sounds like the OP already has a way to solve the matrix once it
>was formed.
>
>But why reinvent the wheel? I'm sure you can find a lsq fit or at
>least a linear equation solver for the msp430 in C or even in ASM.

Just offered something I had handy.

Jon
------------------------------------

______________________________
controlSUITE™ software. Comprehensive. Intuitive. Optimized.
Real-world software for real-time control. Details Here!



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: creating and solving 3rd order equations from data points - Mike - Jul 18 10:34:16 2009

Well, yes, all the i's should have been included... but at that point in the "conversation", that was assumed. Since we only have plain text here, it's difficult and confusing to try to put in summation symbols and subscripts...

--- In m...@yahoogroups.com, Henry Liu wrote:
>
> Ya the RHS should be:
> sum(yi)
> sum(xi*yi)
> ...sum(x^3*y)
>
> I always knew a PhD from Stanford and math minor would teach me something.
>
> On Fri, Jul 17, 2009 at 4:19 AM, Jon Kirwan wrote:
> >
> >
> > On Thu, 16 Jul 2009 09:43:38 -0700, Henry Liu wrote:
> >>
> >>On Thu, Jul 16, 2009 at 8:46 AM, Mike wrote:
> >>>
> >>> Hi Henry,
> >>>
> >>> I saw the website you listed, plus several others... Let me walk through
> >>> this to verify my thinking...
> >>>
> >>> For linear regression, as I understand it, the matrix looks like this:
> >>>
> >>> [
> >>> n sum(x) sum(x^2) sum(x^3) -sum(y)
> >>> sum(x) sum(x^2) sum(x^3) sum(x^4) -sum(x)sum(y)
> >>> sum(x^2) sum(x^3) sum(x^4) sum(x^5) -sum(x^2)sum(y)
> >>> sum(x^3) sum(x^4) sum(x^5) sum(x^6) -sum(x^3)sum(y)
> >>> ]
> >>>
> >>
> >>>
> >>> Thanks,
> >>> Mike.
> >>>
> >>I think you flipped a minus sign:
> >>
> >>http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html
> >>
> >>eqn 9 is equiv to running Guass jordan elimination on:
> >>
> >>[
> >>n sum(x) sum(x^2) sum(x^3) sum(y)
> >>sum(x) sum(x^2) sum(x^3) sum(x^4) sum(x)sum(y)
> >>sum(x^2) sum(x^3) sum(x^4) sum(x^5) sum(x^2)sum(y)
> >>sum(x^3) sum(x^4) sum(x^5) sum(x^6) sum(x^3)sum(y)
> >>]
> >
> > Has everyone somehow forgotten how to read bog-standard summation
> > notation?? The above examples, both the one from Mike interpreting
> > the offered web page __and__ the 'corrected' one from Henry somehow
> > managed to each fail to read the web page accurately.
> >
> > Take a look at the right column vector on the web page for equation 9
> > (or 12, I suppose.) A close look. See if you can spot the problem
> > between the above transliterations and the original work on the web
> > page.
> >
> > Jon
> >
>

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: creating and solving 3rd order equations from data points - Mike - Jul 18 11:11:19 2009

You'd think it would be easy to find code for either lsq fit or or solving linear equations on the web, but there's not much out there. You can find specific equations or code for 2nd order, but above that, it's generalized or "an exercise left for the reader". It's been about 30 years since I had any sort of math like this in school, so it was rough wading through all the terminology that I just barely remember. There are some libraries (usually without source code, and written for PC's) that I couldn't possibly pull into my microcontroller design, so I ended up writing it myself. I even went out looking for university math professors, but they're all on vacation for the summer...

In any case, the problems were due to the flipped signs and an error in the routine for zeroing out the right side of the matrix (it would zero the terms, but not update the columns to the right). It's working and giving me data that matches the Excel results. Henry was a great help - besides seeing the flipped signs, it helped to have someone who knew what they were doing to validate my math, which narrowed the search for the problems.

Henry, thanks for your help, and thanks to the rest of you for the interesting discussions.

Mike.
--- In m...@yahoogroups.com, Henry Liu wrote:
> But why reinvent the wheel? I'm sure you can find a lsq fit or at
> least a linear equation solver for the msp430 in C or even in ASM.
>

>> > Now, if someone actually _wants_ C code to do this, I recommend they
> > look up "LDLT decomposition" (the starting matrix is symmetric,

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Re: creating and solving 3rd order equations from data points - Jon Kirwan - Jul 18 14:06:56 2009

On Sat, 18 Jul 2009 13:55:11 -0000, you wrote:

>Well, yes, all the i's should have been included... but at that point
>in the "conversation", that was assumed. Since we only have plain
>text here, it's difficult and confusing to try to put in summation
>symbols and subscripts...

No, Mike. That's not it. Henry got it, right away.

I think you tried (attempted) to see if you could get the right
results with Excel or some spreadsheet, but things hadn't worked out.
If all it was is the above, then you'd probably have gotten the right
results. I strongly suspect the results you didn't properly see were
due to another error that Henry immediately caught and wrote about.

Jon
------------------------------------

______________________________
controlSUITE™ software. Comprehensive. Intuitive. Optimized.
Real-world software for real-time control. Details Here!



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Re: creating and solving 3rd order equations from data points - Henry Liu - Jul 19 0:03:13 2009

For linear equations solving, every respectable platform I know has an
optimized version of LAPACK or at least BLAS. I haven't programmed
the MSP430 to know where to find one but I'm sure most C compilers
have a library for it somewhere. Every scientific computing
programmer should be familiar with these functions in C and Fortran.

Computing matrix inverse, multiplication, LU, QR, etc should never be
written by hand due to performance issues. The optimized BLAS usually
is written in ASM and the order of operations / stack optimization /
threads, etc are all taken into account.

On the otherhand, that link on mathworld I sent for the equation for
lsq polynomial fit is crystal clear. Any more clear and you'd have to
hire a consultant to code it for you.

I'd be happy to handle any of your math problems in exchange for
coding help next time lol.

Henry

On Sat, Jul 18, 2009 at 7:17 AM, Mike wrote:
> You'd think it would be easy to find code for either lsq fit or or solving
> linear equations on the web, but there's not much out there. You can find
> specific equations or code for 2nd order, but above that, it's generalized
> or "an exercise left for the reader". It's been about 30 years since I had
> any sort of math like this in school, so it was rough wading through all the
> terminology that I just barely remember. There are some libraries (usually
> without source code, and written for PC's) that I couldn't possibly pull
> into my microcontroller design, so I ended up writing it myself. I even went
> out looking for university math professors, but they're all on vacation for
> the summer...
>
> In any case, the problems were due to the flipped signs and an error in the
> routine for zeroing out the right side of the matrix (it would zero the
> terms, but not update the columns to the right). It's working and giving me
> data that matches the Excel results. Henry was a great help - besides seeing
> the flipped signs, it helped to have someone who knew what they were doing
> to validate my math, which narrowed the search for the problems.
>
> Henry, thanks for your help, and thanks to the rest of you for the
> interesting discussions.
>
> Mike.
>
> --- In m...@yahoogroups.com, Henry Liu wrote:
>> But why reinvent the wheel? I'm sure you can find a lsq fit or at
>> least a linear equation solver for the msp430 in C or even in ASM.
>>>> > Now, if someone actually _wants_ C code to do this, I recommend they
>> > look up "LDLT decomposition" (the starting matrix is symmetric,
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Re: creating and solving 3rd order equations from data points - Henry Liu - Jul 19 0:07:27 2009

Just make sure you are doing sum(xi*yi) not sum(xi)*sum(yi) which are
not the same thing as Jon pointed out.

In physics, we usually just write XiYi or Xii or Xij and omit the
summation signs all together (Einstein notation).

On Sat, Jul 18, 2009 at 7:17 AM, Mike wrote:
> You'd think it would be easy to find code for either lsq fit or or solving
> linear equations on the web, but there's not much out there. You can find
> specific equations or code for 2nd order, but above that, it's generalized
> or "an exercise left for the reader". It's been about 30 years since I had
> any sort of math like this in school, so it was rough wading through all the
> terminology that I just barely remember. There are some libraries (usually
> without source code, and written for PC's) that I couldn't possibly pull
> into my microcontroller design, so I ended up writing it myself. I even went
> out looking for university math professors, but they're all on vacation for
> the summer...
>
> In any case, the problems were due to the flipped signs and an error in the
> routine for zeroing out the right side of the matrix (it would zero the
> terms, but not update the columns to the right). It's working and giving me
> data that matches the Excel results. Henry was a great help - besides seeing
> the flipped signs, it helped to have someone who knew what they were doing
> to validate my math, which narrowed the search for the problems.
>
> Henry, thanks for your help, and thanks to the rest of you for the
> interesting discussions.
>
> Mike.
>
> --- In m...@yahoogroups.com, Henry Liu wrote:
>> But why reinvent the wheel? I'm sure you can find a lsq fit or at
>> least a linear equation solver for the msp430 in C or even in ASM.
>>>> > Now, if someone actually _wants_ C code to do this, I recommend they
>> > look up "LDLT decomposition" (the starting matrix is symmetric,
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: creating and solving 3rd order equations from data points - John Heenan - Jul 19 10:38:48 2009

Linear least squares smoothing and prediction theory got left behind 50 years ago.

Apart from this, what practical engineering use is there for creating and solving third order equations from data points in an embedded device that is expected to act on real world signals?

If you want to optimally separate noise form a signal then there are well known sophisticated engineering approaches that are amenable to number crunching. The best known example is the Kalman filter, of which the original published paper in 1960 provides a very clear discussion of practical limitations of traditional approaches that incorporate least squares methods (such as the Wiener Filter of the 1940s).

MSP430 devices are not suitable for intensive number crunching, even with the most efficient algorithms.

There are more suitable devices and manufacturers provide optimised C libraries suitable for their devices, such as DSP manufacturers.

John Heenan
--- In m...@yahoogroups.com, "Mike" wrote:
>
> You'd think it would be easy to find code for either lsq fit or or solving linear equations on the web, but there's not much out there. You can find specific equations or code for 2nd order, but above that, it's generalized or "an exercise left for the reader". It's been about 30 years since I had any sort of math like this in school, so it was rough wading through all the terminology that I just barely remember. There are some libraries (usually without source code, and written for PC's) that I couldn't possibly pull into my microcontroller design, so I ended up writing it myself. I even went out looking for university math professors, but they're all on vacation for the summer...
>
> In any case, the problems were due to the flipped signs and an error in the routine for zeroing out the right side of the matrix (it would zero the terms, but not update the columns to the right). It's working and giving me data that matches the Excel results. Henry was a great help - besides seeing the flipped signs, it helped to have someone who knew what they were doing to validate my math, which narrowed the search for the problems.
>
> Henry, thanks for your help, and thanks to the rest of you for the interesting discussions.
>
> Mike.
> --- In m...@yahoogroups.com, Henry Liu wrote:
> > But why reinvent the wheel? I'm sure you can find a lsq fit or at
> > least a linear equation solver for the msp430 in C or even in ASM.
> > >> > Now, if someone actually _wants_ C code to do this, I recommend they
> > > look up "LDLT decomposition" (the starting matrix is symmetric,
>

------------------------------------

______________________________
controlSUITE™ software. Comprehensive. Intuitive. Optimized.
Real-world software for real-time control. Details Here!



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: creating and solving 3rd order equations from data points - John Heenan - Jul 19 11:44:17 2009

Before anyone has a go at me for apparently labelling third order equations as linear equations, 'linear' below refers to 'linear systems'

Linear systems are assumed to possess, or be close enough to possess, properties of superposition and scaling for modelling purposes.

Noise of course ruins everything. This is where 'least squares' methods and other improved methods can attempt to repair the damage of the real world rudely intruding on nice tidy idealised linear system perfect models so beloved of text books.

The accepted engineering terminology for attempting to recover intelligibility from noise is filtering.

It would be nice to get back on a track relevant to the MSP430 and its users.

John Heenan

--- In m...@yahoogroups.com, "John Heenan" wrote:
>
> Linear least squares smoothing and prediction theory got left behind 50 years ago.
>
> Apart from this, what practical engineering use is there for creating and solving third order equations from data points in an embedded device that is expected to act on real world signals?
>
> If you want to optimally separate noise form a signal then there are well known sophisticated engineering approaches that are amenable to number crunching. The best known example is the Kalman filter, of which the original published paper in 1960 provides a very clear discussion of practical limitations of traditional approaches that incorporate least squares methods (such as the Wiener Filter of the 1940s).
>
> MSP430 devices are not suitable for intensive number crunching, even with the most efficient algorithms.
>
> There are more suitable devices and manufacturers provide optimised C libraries suitable for their devices, such as DSP manufacturers.
>
> John Heenan
> --- In m...@yahoogroups.com, "Mike" wrote:
> >
> > You'd think it would be easy to find code for either lsq fit or or solving linear equations on the web, but there's not much out there. You can find specific equations or code for 2nd order, but above that, it's generalized or "an exercise left for the reader". It's been about 30 years since I had any sort of math like this in school, so it was rough wading through all the terminology that I just barely remember. There are some libraries (usually without source code, and written for PC's) that I couldn't possibly pull into my microcontroller design, so I ended up writing it myself. I even went out looking for university math professors, but they're all on vacation for the summer...
> >
> > In any case, the problems were due to the flipped signs and an error in the routine for zeroing out the right side of the matrix (it would zero the terms, but not update the columns to the right). It's working and giving me data that matches the Excel results. Henry was a great help - besides seeing the flipped signs, it helped to have someone who knew what they were doing to validate my math, which narrowed the search for the problems.
> >
> > Henry, thanks for your help, and thanks to the rest of you for the interesting discussions.
> >
> > Mike.
> >
> >
> > --- In m...@yahoogroups.com, Henry Liu wrote:
> > > But why reinvent the wheel? I'm sure you can find a lsq fit or at
> > > least a linear equation solver for the msp430 in C or even in ASM.
> > >
> >
> >
> >
> > >> > Now, if someone actually _wants_ C code to do this, I recommend they
> > > > look up "LDLT decomposition" (the starting matrix is symmetric,
>

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: creating and solving 3rd order equations from data points - Mike - Jul 22 10:53:57 2009

John,

That's sort of a head-in-the-sand attitude... Mathematics is a tool, and who's to say which method is best for a particular problem? In this case, it isn't a matter of filtering noise - it turns out that least squares closely predicts what I'm doing, given as few as 4 data points.

This isn't what I did on this project, but here's a real-world example relevant to MSP430:

Take a look at the datasheet for a 32KHz crystal, and the "frequency vs. temperature" curve. It looks like an upside down parabola, with more deviation from 32768 as you get away from 20 degrees C. There's also an up/down shift of the curve from crystal to crystal, and some small difference in slope between high and low temperatures. From crystal to crystal (and also affected by the board capacitance around the crystals), the "center" might shift as much as 5 degrees from 20C . The deviation from the center frequency looks looks like a parabola going up on the positive side, it flattens near 20C, and looks like a parabola going down on the low temp side. This can be modeled very closely by an equation that looks like y = Dx^3 + Cx^2 + Bx + A (where y is frequency and x is temperature).

Let's say you want your real time clock to be accurate in varying temperatures to less than a couple of minutes per year. For a lot of reasons, you can't sync to a clock broadcast or whatever, so you want to take a couple of readings at temperature and calibrate. You could take readings at 20C and say 40C, fake a couple of readings close to 20C (since they're within a couple of ppm to the 20C reading), and generate (using least squares and solving linear equations) an equation that predicts the output frequency at a particular temperature.

Since you can use the internal temperature sensor on any MSP430 that has an ADC, then you can pretty effectively compensate the frequency vs. temperature. If you decide that you need more accuracy, or that the negative side is different from the positive side, you take more data points... Expensive and difficult to vary temperature, maybe, but that's an engineering tradeoff. Maybe you find that it's consistent for a batch of crystals, and you only have to test one unit for every reel of crystals...

Ah, you say, I can spend a little more and get 5 ppm crystals... Well, that takes care of the up/down shift in the curve, but not capacitance differences due to manufacturing, or variation from temperature dependence. The deviation across temperature is a couple hundred ppm. If you subtract temperature deviation, you might be able to get the frequency error down to 5 or 10 ppm, or whatever your spec requires.

I'm not saying this is a perfect example, or it's the best solution for all cases, but it's certainly demonstrates that least squares can be a valid tool in the engineer's toolbox. There seem to be lots of sensor types that have a "sweet spot" and the error increases the further away you get from the center reading. For some sensors, taking a few calibration readings may be a lot easier to automate than varying temperature.

Again, many thanks to the people who gave positive feedback here, especially Henry!

Mike.
--- In m...@yahoogroups.com, "John Heenan" wrote:
>
> Linear least squares smoothing and prediction theory got left behind 50 years ago.
>
> Apart from this, what practical engineering use is there for creating and solving third order equations from data points in an embedded device that is expected to act on real world signals?
>
> If you want to optimally separate noise form a signal then there are well known sophisticated engineering approaches that are amenable to number crunching. The best known example is the Kalman filter, of which the original published paper in 1960 provides a very clear discussion of practical limitations of traditional approaches that incorporate least squares methods (such as the Wiener Filter of the 1940s).
>
> MSP430 devices are not suitable for intensive number crunching, even with the most efficient algorithms.
>
> There are more suitable devices and manufacturers provide optimised C libraries suitable for their devices, such as DSP manufacturers.
>
> John Heenan
>

------------------------------------

______________________________
controlSUITE™ software. Comprehensive. Intuitive. Optimized.
Real-world software for real-time control. Details Here!



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Re: creating and solving 3rd order equations from data points - Henry Liu - Jul 23 19:52:56 2009

No problem in helping out but I don't understand your example.

I understand you can have a LUT with various temperature compensations
as supplied by the manufacturer but why do you need to LSQ fit the
data on the MSP430?

I will assume you have a gold standard temp compensated freq and then
measure it with the MSP430 with the crystal under test with varying
temp then calculate the true freq of the crystal.

But why not just record the freq as a function of temp and use a look up table?

This will be way more accurate + less computationally less intensive
than assuming it's cubic. Mostly because that temp func of your
MSP430 isn't that accurate you are making a lot of other assumptions.
I wouldn't even bother interpolating the freq, just round it to the
next value in your LUT.

On Wed, Jul 22, 2009 at 7:53 AM, Mike wrote:
> John,
>
> That's sort of a head-in-the-sand attitude... Mathematics is a tool, and
> who's to say which method is best for a particular problem? In this case, it
> isn't a matter of filtering noise - it turns out that least squares closely
> predicts what I'm doing, given as few as 4 data points.
>
> This isn't what I did on this project, but here's a real-world example
> relevant to MSP430:
>
> Take a look at the datasheet for a 32KHz crystal, and the "frequency vs.
> temperature" curve. It looks like an upside down parabola, with more
> deviation from 32768 as you get away from 20 degrees C. There's also an
> up/down shift of the curve from crystal to crystal, and some small
> difference in slope between high and low temperatures. From crystal to
> crystal (and also affected by the board capacitance around the crystals),
> the "center" might shift as much as 5 degrees from 20C . The deviation from
> the center frequency looks looks like a parabola going up on the positive
> side, it flattens near 20C, and looks like a parabola going down on the low
> temp side. This can be modeled very closely by an equation that looks like y
> = Dx^3 + Cx^2 + Bx + A (where y is frequency and x is temperature).
>
> Let's say you want your real time clock to be accurate in varying
> temperatures to less than a couple of minutes per year. For a lot of
> reasons, you can't sync to a clock broadcast or whatever, so you want to
> take a couple of readings at temperature and calibrate. You could take
> readings at 20C and say 40C, fake a couple of readings close to 20C (since
> they're within a couple of ppm to the 20C reading), and generate (using
> least squares and solving linear equations) an equation that predicts the
> output frequency at a particular temperature.
>
> Since you can use the internal temperature sensor on any MSP430 that has an
> ADC, then you can pretty effectively compensate the frequency vs.
> temperature. If you decide that you need more accuracy, or that the negative
> side is different from the positive side, you take more data points...
> Expensive and difficult to vary temperature, maybe, but that's an
> engineering tradeoff. Maybe you find that it's consistent for a batch of
> crystals, and you only have to test one unit for every reel of crystals...
>
> Ah, you say, I can spend a little more and get 5 ppm crystals... Well, that
> takes care of the up/down shift in the curve, but not capacitance
> differences due to manufacturing, or variation from temperature dependence.
> The deviation across temperature is a couple hundred ppm. If you subtract
> temperature deviation, you might be able to get the frequency error down to
> 5 or 10 ppm, or whatever your spec requires.
>
> I'm not saying this is a perfect example, or it's the best solution for all
> cases, but it's certainly demonstrates that least squares can be a valid
> tool in the engineer's toolbox. There seem to be lots of sensor types that
> have a "sweet spot" and the error increases the further away you get from
> the center reading. For some sensors, taking a few calibration readings may
> be a lot easier to automate than varying temperature.
>
> Again, many thanks to the people who gave positive feedback here, especially
> Henry!
>
> Mike.
>
> --- In m...@yahoogroups.com, "John Heenan" wrote:
>>
>> Linear least squares smoothing and prediction theory got left behind 50
>> years ago.
>>
>> Apart from this, what practical engineering use is there for creating and
>> solving third order equations from data points in an embedded device that is
>> expected to act on real world signals?
>>
>> If you want to optimally separate noise form a signal then there are well
>> known sophisticated engineering approaches that are amenable to number
>> crunching. The best known example is the Kalman filter, of which the
>> original published paper in 1960 provides a very clear discussion of
>> practical limitations of traditional approaches that incorporate least
>> squares methods (such as the Wiener Filter of the 1940s).
>>
>> MSP430 devices are not suitable for intensive number crunching, even with
>> the most efficient algorithms.
>>
>> There are more suitable devices and manufacturers provide optimised C
>> libraries suitable for their devices, such as DSP manufacturers.
>>
>> John Heenan
>>
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: creating and solving 3rd order equations from data points - Mike - Jul 26 23:27:09 2009

Hi Henry,

A gold standard only works if you have consistent units... What if the frequency (or whatever) vary from unit to unit? (i.e. there is no gold standard) What if it takes an hour to run through the full temperature range? If you can take two readings and assume a couple of data points close to zero and get a good approximation, that might be good enough... I actually implemented this example using a gold standard and a lookup table a few years ago (because, yes, it was consistent from unit to unit).

I can't talk about my current design, but it just so happens that the sensors I'm using have exactly the same error profile (it's not temperature related, though). The sensors vary from unit to unit, so every unit needs to be calibrated, and it just isn't practical to take enough readings to create a lookup table. The customer can take as many readings as they want to get the precision they want (realizing, of course, that at some point, more readings don't bring more precision).

I didn't really assume this was cubic - for my current design, I took actual data from sensors and put it into Excel. The best fit was with a cubic equation, and the more points I added, the better it predicted error. But it's "good enough" with only 5-7 points (3 of which can be estimated near the zero-slope point). Try it - take the crystal temp/freq error curve and enter 5-10 points into Excel, and you'll get a perfect fit with a cubic.

Mike.

--- In m...@yahoogroups.com, Henry Liu wrote:
>
> No problem in helping out but I don't understand your example.
>
> I understand you can have a LUT with various temperature compensations
> as supplied by the manufacturer but why do you need to LSQ fit the
> data on the MSP430?
>
> I will assume you have a gold standard temp compensated freq and then
> measure it with the MSP430 with the crystal under test with varying
> temp then calculate the true freq of the crystal.
>
> But why not just record the freq as a function of temp and use a look up table?
>
> This will be way more accurate + less computationally less intensive
> than assuming it's cubic. Mostly because that temp func of your
> MSP430 isn't that accurate you are making a lot of other assumptions.
> I wouldn't even bother interpolating the freq, just round it to the
> next value in your LUT.
>
> On Wed, Jul 22, 2009 at 7:53 AM, Mike wrote:
> >
> >
> > John,
> >
> > That's sort of a head-in-the-sand attitude... Mathematics is a tool, and
> > who's to say which method is best for a particular problem? In this case, it
> > isn't a matter of filtering noise - it turns out that least squares closely
> > predicts what I'm doing, given as few as 4 data points.
> >
> > This isn't what I did on this project, but here's a real-world example
> > relevant to MSP430:
> >
> > Take a look at the datasheet for a 32KHz crystal, and the "frequency vs.
> > temperature" curve. It looks like an upside down parabola, with more
> > deviation from 32768 as you get away from 20 degrees C. There's also an
> > up/down shift of the curve from crystal to crystal, and some small
> > difference in slope between high and low temperatures. From crystal to
> > crystal (and also affected by the board capacitance around the crystals),
> > the "center" might shift as much as 5 degrees from 20C . The deviation from
> > the center frequency looks looks like a parabola going up on the positive
> > side, it flattens near 20C, and looks like a parabola going down on the low
> > temp side. This can be modeled very closely by an equation that looks like y
> > = Dx^3 + Cx^2 + Bx + A (where y is frequency and x is temperature).
> >
> > Let's say you want your real time clock to be accurate in varying
> > temperatures to less than a couple of minutes per year. For a lot of
> > reasons, you can't sync to a clock broadcast or whatever, so you want to
> > take a couple of readings at temperature and calibrate. You could take
> > readings at 20C and say 40C, fake a couple of readings close to 20C (since
> > they're within a couple of ppm to the 20C reading), and generate (using
> > least squares and solving linear equations) an equation that predicts the
> > output frequency at a particular temperature.
> >
> > Since you can use the internal temperature sensor on any MSP430 that has an
> > ADC, then you can pretty effectively compensate the frequency vs.
> > temperature. If you decide that you need more accuracy, or that the negative
> > side is different from the positive side, you take more data points...
> > Expensive and difficult to vary temperature, maybe, but that's an
> > engineering tradeoff. Maybe you find that it's consistent for a batch of
> > crystals, and you only have to test one unit for every reel of crystals...
> >
> > Ah, you say, I can spend a little more and get 5 ppm crystals... Well, that
> > takes care of the up/down shift in the curve, but not capacitance
> > differences due to manufacturing, or variation from temperature dependence.
> > The deviation across temperature is a couple hundred ppm. If you subtract
> > temperature deviation, you might be able to get the frequency error down to
> > 5 or 10 ppm, or whatever your spec requires.
> >
> > I'm not saying this is a perfect example, or it's the best solution for all
> > cases, but it's certainly demonstrates that least squares can be a valid
> > tool in the engineer's toolbox. There seem to be lots of sensor types that
> > have a "sweet spot" and the error increases the further away you get from
> > the center reading. For some sensors, taking a few calibration readings may
> > be a lot easier to automate than varying temperature.
> >
> > Again, many thanks to the people who gave positive feedback here, especially
> > Henry!
> >
> > Mike.
> >
> > --- In m...@yahoogroups.com, "John Heenan" wrote:
> >>
> >> Linear least squares smoothing and prediction theory got left behind 50
> >> years ago.
> >>
> >> Apart from this, what practical engineering use is there for creating and
> >> solving third order equations from data points in an embedded device that is
> >> expected to act on real world signals?
> >>
> >> If you want to optimally separate noise form a signal then there are well
> >> known sophisticated engineering approaches that are amenable to number
> >> crunching. The best known example is the Kalman filter, of which the
> >> original published paper in 1960 provides a very clear discussion of
> >> practical limitations of traditional approaches that incorporate least
> >> squares methods (such as the Wiener Filter of the 1940s).
> >>
> >> MSP430 devices are not suitable for intensive number crunching, even with
> >> the most efficient algorithms.
> >>
> >> There are more suitable devices and manufacturers provide optimised C
> >> libraries suitable for their devices, such as DSP manufacturers.
> >>
> >> John Heenan
> >>
> >
>

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )