f



optimization #2 789967

Hello everybody, I'm a post-gratuate student from greece and since my
math and software knowledge is limited I seem to find it difficult to
solve the problem below.

So this is the case:................

After conducting an experiment I've collected some (323) values. 

I know that those values come from the equation:

value = A*x^2 + B*y^2 + C*z^2 + 2*D*x*y + 2*E*y*z + 2*F*z*x

x, y and z are known and different for each value.

My aim is to calculate the optimum values of A, B, C, D, E and F 
for which the values that will come up by the use of the equation will
be as close they can get to the experimental.

I know for a fact that A,B and C are between 0-1 and D,E and F between
(-1)-1

What I've done so far:..............

x, y and z are limited numbers(mixed up cosines with sines and staff
like that)

So I choose randomly a heaxad values for A-F and calculate the below
sum

sum from i=1 to 323 ev(i)-value(equation)

After that I choose a different hexad and calculate the new sum.

Lets say, after 100 different hexads the one where the sum is minimum
is reported.

This story continues for 100 times so from 100x100 sums I collect the
hexads of the 100 minimun.

These hexads litim the values of A-F. For example the A of the ortimum
hexads is now between 0.2-0.5 etc...

I rerun the same program having change the limits where A-F take their
random values.

I keep doing this until I get variation of A-F value under the third
decomal
e.g. A [0.356 - 0.369]

I want to know if there is a faster easier or more secure way to
calculate the optimum values of A-F.

I used matlab to run the prementioned optimisation which is the only
one I know (I've learned it only to solve this problem) so if someone
has a set solution of a program for matlab ot would be much
appreciated.


I know it was to long a letter so even if you don't know the answer to
my problem I ought to thank you for your time.

TIA spiros.
0
tzabal (2)
10/1/2003 11:28:35 AM
comp.soft-sys.matlab 211266 articles. 15 followers. lunamoonmoon (258) is leader. Post Follow

12 Replies
670 Views

Similar Articles

[PageSpeed] 4

A short question, before I post my answer: Do you know LaTeX notation?
That would make an answer much easier.

-- 
Andreas
For replying, remove the fruit from my address.


0
10/1/2003 11:44:51 AM
"tzavalas" <tzabal@hotmail.com> wrote:
> After conducting an experiment I've collected some (323) values.
> I know that those values come from the equation:
> value = A*x^2 + B*y^2 + C*z^2 + 2*D*x*y + 2*E*y*z + 2*F*z*x
> x, y and z are known and different for each value.
> My aim is to calculate the optimum values of A, B, C, D, E and F
> for which the values that will come up by the use of the equation will
> be as close they can get to the experimental.

This is a typical problem called least squares approximation.

> I know for a fact that A,B and C are between 0-1 and D,E and F between
> (-1)-1

That's nice to know (for checking the solution) but not needed in the
following.

> What I've done so far:..............
> x, y and z are limited numbers(mixed up cosines with sines and staff
> like that)
> So I choose randomly a heaxad values for A-F and calculate the below
> sum
> sum from i=1 to 323 ev(i)-value(equation)
> After that I choose a different hexad and calculate the new sum.
> Lets say, after 100 different hexads the one where the sum is minimum
> is reported.
> This story continues for 100 times so from 100x100 sums I collect the
> hexads of the 100 minimun.
> These hexads litim the values of A-F. For example the A of the ortimum
> hexads is now between 0.2-0.5 etc...
> I rerun the same program having change the limits where A-F take their
> random values.
> I keep doing this until I get variation of A-F value under the third
> decomal
> e.g. A [0.356 - 0.369]

Wow, that's really "unmathematical". Stop it. It sounds weird,
time-consuming and not exact. (I didn't read on after "100 times".

> I want to know if there is a faster easier or more secure way to
> calculate the optimum values of A-F.

Yep, there's a very fast, easy and stable algorithm to do this based on
the so-called QR decomposition of a matrix.

The following code between the "=====" lines is valid LaTeX code. Just
put it into a file and run LaTeX to get a nicer output, if you don't
want to read the code in text form. (If you don't have/know LaTeX, I can
send you a PDF file, if you give me your e-mail address.)

==============================
\documentclass{article}
\begin{document}
Let's call your "equation values" $b_1,\ldots,b_n$, where $n=323$ in
your case.
Similarly let $x_1,\ldots,x_n$ be the $x$ values, $y_1,\ldots,y_n$ the
$y$ values, and $z_1,\ldots,z_n$ the $z$ values you obtained from your
experiment.

Then let $A$ be your data matrix
$$
A = \left( \begin{array}{cccccc}
    x_1^2 & y_1^2 & z_1^2 & x_1 y_1 & y_1 z_1 & x_1 z_1 \\
    \vdots & \vdots & \vdots & \vdots & \vdots & \vdots \\
    x_n^2 & y_n^2 & z_n^2 & x_n y_n & y_n z_n & x_n z_n
\end{array} \right),
$$
let $b$ your vector of experimental values
$$
b = \left( \begin{array}{c}
    b_1 \\ \vdots \\ b_n
\end{array} \right),
$$
and let $x$ be the vector of values you are searching for
$$
x = \left( \begin{array}{c}
    A \\ B \\ C \\ 2D \\ 2E \\ 2F
\end{array} \right).
$$

Then you can write your optimatzation problem as follows:
$$
min_x \left\| A x - b \right\|_2
$$

Remark: You can bring all "parameter fitting problems" into this form if
the equation is linear in the parameters ($A$ to $2F$ in your case).

There are several ways to solve this. Two of them are:
\begin{itemize}
\item Solve the linear equation
$$
    A^T A x = A^T b
$$
using the Gau\ss-Algorithm (LR decomposition of $A^T A$).
\item Solve the problem by using the QR decomposition of $A$
$$
    A = Q R
$$
which produces an orthogonal matrix $Q$ and an upper right matrix $R$.
Then the minimazation problem is equivalent to the following linear
equation for $x$
$$
    R x = Q^T b
$$
which can be easily solved, because $R$ has upper-right form.
\end{itemize}

The first method is not recommended, since it uses more operations then
necessary and is not as stable as the second one.

\end{document}
==============================

> I used matlab to run the prementioned optimisation which is the only
> one I know (I've learned it only to solve this problem) so if someone
> has a set solution of a program for matlab ot would be much
> appreciated.

Here comes the MatLab code, assuming you built the A matrix and b vector
as explained above.

For applying the second (stable) method, use the following commands:
% perform QR decomposition of A
[Q R] = qr(A);
% calculate solution of R x = Q^T b
x = R\(Q'*b);

The Matlab help to the QR algorithm proposes sth. based on a mixture of
the two methods which should also be very reliable:
% perform QR decomposition of A
[Q R] = qr(A);
% calculate the solution of R^T R x (= A^T A x) = A^T b
x = R\(R'\(A'*b));

So, you only have to build the matrix A, vector b and enter two command
lines to obtain your solution x=(A,B,C,2D,2E,2F).

The 2 methods normally are working equally reliable and are very fast
and accurate. You could even use much more data samples then 323.

If you want to check the accuracy, you can (in both cases) perform a
correction step:
% calculate residual
r = b - A*x;
% calculate error correction step (depending on which
% method you prefer), which should be incredible small
e = R\(Q'*b);
   OR
e = R\(R'\(A'*r));
% add correction to solution vector
x = x + e;

A final note:
I realized that your equation has a quadratic form. It can be written as
(this time it's ASCII art for better understanding):
          |A D F|   |x|
|x y z| * |D B E| * |y|
          |F E C|   |z|
Therefore I think, there could be an even better solution to the
optimization problem which uses the special structure of the equation.
But I'm too lazy to think about it for the time being, sorry.

-- 
Andreas
For replying, remove the fruit from my address.


0
10/1/2003 1:04:00 PM
This is a good starting place, but the problem is neither linear or normal,
so if it does not lead to a satisfactory solution you may want to consider
the maximum likelihood estimation method.

"Andreas Keil" <andreas.keil@apple.nurfuerspam.de> wrote in message
news:blejc1$g88$1@news-sop.inria.fr...
> "tzavalas" <tzabal@hotmail.com> wrote:
> > After conducting an experiment I've collected some (323) values.
> > I know that those values come from the equation:
> > value = A*x^2 + B*y^2 + C*z^2 + 2*D*x*y + 2*E*y*z + 2*F*z*x
> > x, y and z are known and different for each value.
> > My aim is to calculate the optimum values of A, B, C, D, E and F
> > for which the values that will come up by the use of the equation will
> > be as close they can get to the experimental.
>
> This is a typical problem called least squares approximation.
>
> > I know for a fact that A,B and C are between 0-1 and D,E and F between
> > (-1)-1
>
> That's nice to know (for checking the solution) but not needed in the
> following.
>
> > What I've done so far:..............
> > x, y and z are limited numbers(mixed up cosines with sines and staff
> > like that)
> > So I choose randomly a heaxad values for A-F and calculate the below
> > sum
> > sum from i=1 to 323 ev(i)-value(equation)
> > After that I choose a different hexad and calculate the new sum.
> > Lets say, after 100 different hexads the one where the sum is minimum
> > is reported.
> > This story continues for 100 times so from 100x100 sums I collect the
> > hexads of the 100 minimun.
> > These hexads litim the values of A-F. For example the A of the ortimum
> > hexads is now between 0.2-0.5 etc...
> > I rerun the same program having change the limits where A-F take their
> > random values.
> > I keep doing this until I get variation of A-F value under the third
> > decomal
> > e.g. A [0.356 - 0.369]
>
> Wow, that's really "unmathematical". Stop it. It sounds weird,
> time-consuming and not exact. (I didn't read on after "100 times".
>
> > I want to know if there is a faster easier or more secure way to
> > calculate the optimum values of A-F.
>
> Yep, there's a very fast, easy and stable algorithm to do this based on
> the so-called QR decomposition of a matrix.
>
> The following code between the "=====" lines is valid LaTeX code. Just
> put it into a file and run LaTeX to get a nicer output, if you don't
> want to read the code in text form. (If you don't have/know LaTeX, I can
> send you a PDF file, if you give me your e-mail address.)
>
> ==============================
> \documentclass{article}
> \begin{document}
> Let's call your "equation values" $b_1,\ldots,b_n$, where $n=323$ in
> your case.
> Similarly let $x_1,\ldots,x_n$ be the $x$ values, $y_1,\ldots,y_n$ the
> $y$ values, and $z_1,\ldots,z_n$ the $z$ values you obtained from your
> experiment.
>
> Then let $A$ be your data matrix
> $$
> A = \left( \begin{array}{cccccc}
>     x_1^2 & y_1^2 & z_1^2 & x_1 y_1 & y_1 z_1 & x_1 z_1 \\
>     \vdots & \vdots & \vdots & \vdots & \vdots & \vdots \\
>     x_n^2 & y_n^2 & z_n^2 & x_n y_n & y_n z_n & x_n z_n
> \end{array} \right),
> $$
> let $b$ your vector of experimental values
> $$
> b = \left( \begin{array}{c}
>     b_1 \\ \vdots \\ b_n
> \end{array} \right),
> $$
> and let $x$ be the vector of values you are searching for
> $$
> x = \left( \begin{array}{c}
>     A \\ B \\ C \\ 2D \\ 2E \\ 2F
> \end{array} \right).
> $$
>
> Then you can write your optimatzation problem as follows:
> $$
> min_x \left\| A x - b \right\|_2
> $$
>
> Remark: You can bring all "parameter fitting problems" into this form if
> the equation is linear in the parameters ($A$ to $2F$ in your case).
>
> There are several ways to solve this. Two of them are:
> \begin{itemize}
> \item Solve the linear equation
> $$
>     A^T A x = A^T b
> $$
> using the Gau\ss-Algorithm (LR decomposition of $A^T A$).
> \item Solve the problem by using the QR decomposition of $A$
> $$
>     A = Q R
> $$
> which produces an orthogonal matrix $Q$ and an upper right matrix $R$.
> Then the minimazation problem is equivalent to the following linear
> equation for $x$
> $$
>     R x = Q^T b
> $$
> which can be easily solved, because $R$ has upper-right form.
> \end{itemize}
>
> The first method is not recommended, since it uses more operations then
> necessary and is not as stable as the second one.
>
> \end{document}
> ==============================
>
> > I used matlab to run the prementioned optimisation which is the only
> > one I know (I've learned it only to solve this problem) so if someone
> > has a set solution of a program for matlab ot would be much
> > appreciated.
>
> Here comes the MatLab code, assuming you built the A matrix and b vector
> as explained above.
>
> For applying the second (stable) method, use the following commands:
> % perform QR decomposition of A
> [Q R] = qr(A);
> % calculate solution of R x = Q^T b
> x = R\(Q'*b);
>
> The Matlab help to the QR algorithm proposes sth. based on a mixture of
> the two methods which should also be very reliable:
> % perform QR decomposition of A
> [Q R] = qr(A);
> % calculate the solution of R^T R x (= A^T A x) = A^T b
> x = R\(R'\(A'*b));
>
> So, you only have to build the matrix A, vector b and enter two command
> lines to obtain your solution x=(A,B,C,2D,2E,2F).
>
> The 2 methods normally are working equally reliable and are very fast
> and accurate. You could even use much more data samples then 323.
>
> If you want to check the accuracy, you can (in both cases) perform a
> correction step:
> % calculate residual
> r = b - A*x;
> % calculate error correction step (depending on which
> % method you prefer), which should be incredible small
> e = R\(Q'*b);
>    OR
> e = R\(R'\(A'*r));
> % add correction to solution vector
> x = x + e;
>
> A final note:
> I realized that your equation has a quadratic form. It can be written as
> (this time it's ASCII art for better understanding):
>           |A D F|   |x|
> |x y z| * |D B E| * |y|
>           |F E C|   |z|
> Therefore I think, there could be an even better solution to the
> optimization problem which uses the special structure of the equation.
> But I'm too lazy to think about it for the time being, sorry.
>
> --
> Andreas
> For replying, remove the fruit from my address.
>
>


0
10/1/2003 1:30:48 PM
"Rod" <RodRodRodRod@hotmail.com> wrote:
> This is a good starting place, but the problem is neither linear or
normal,
> so if it does not lead to a satisfactory solution you may want to
consider
> the maximum likelihood estimation method.

Sorry, but I can't see any nonlinearity in the unknow parameters A, ...,
2F. Where do you see them?

And yes, parameter fitting is quite normal. Thousands of people do it
every day.

And why do you want to make things more comlicated than they are? This
algorithm is one of the most stable algorithm known in mathematics. I'm
not sure, because my statistics lectures are far away, but I think a
solution to maximum likelihood estimation can be obtained by the same
algorithms? (I may be wrong in this point.)

-- 
Andreas
For replying, remove the fruit from my address.


0
10/1/2003 1:41:40 PM
[F-up set to comp.soft-sys.matlab]

tzabal@hotmail.com (tzavalas) writes:

> After conducting an experiment I've collected some (323) values. 
>
> I know that those values come from the equation:
>
> value = A*x^2 + B*y^2 + C*z^2 + 2*D*x*y + 2*E*y*z + 2*F*z*x
>
> x, y and z are known and different for each value.
>
> My aim is to calculate the optimum values of A, B, C, D, E and F 
> for which the values that will come up by the use of the equation will
> be as close they can get to the experimental.
>
> I know for a fact that A,B and C are between 0-1 and D,E and F between
> (-1)-1

I think you'll want a constrained least-square solution.  Imagine that
you construct a matrix for the x^2, y^2, etc values:

x1^2 y1^2 z1^2 2*x1*y1 2*y1*z1 2*z1*x1
x2^2 y2^2 z2^2 2*x2*y2 2*y2*z2 2*z2*x2
x3^2 y3^2 z3^2 2*x3*y3 2*y3*z3 2*z3*x3
....

Call it C.  Now when you multiply this by a vector x, defined as
[A B C D E F]', you get another vector of your "values" (call them y).
x is unknown, so you want to minimize (C*x - y).^2.  If there were no
constraints, you could just do x = C\y;  But since you have
constraints for x, you can use lsqlin instead, which allows
constraints, again specified by a matrix and a vector.  The first few rows
might look like:

[1  0 0 0 0 0] * x <= [1]
[-1 0 0 0 0 0]        [1]
[0  1 0 0 0 0]        [1]


Give it a shot!

-- 
Peter Boettcher <boettcher@ll.mit.edu>
MIT Lincoln Laboratory
MATLAB FAQ: http://www.mit.edu/~pwb/cssm/
0
boettcher (2304)
10/1/2003 1:47:49 PM

>
> Sorry, but I can't see any nonlinearity in the unknow parameters A, ...,
> 2F. Where do you see them?


large values of x, y, z contribute disproportionately


>
> And yes, parameter fitting is quite normal. Thousands of people do it
> every day.


I meant normal in the sense of Gaussian.

>
> And why do you want to make things more comlicated than they are?

Because you may get a different answer, if the constraints are violated then
it maybe worth looking into.
I agree LS will probably do the job, but as I don't know what the OP is
trying to achieve I provided the information so they could choose.

>I'm
> not sure, because my statistics lectures are far away, but I think a
> solution to maximum likelihood estimation can be obtained by the same
> algorithms? (I may be wrong in this point.)


for y=a+bx and "normal" data it can.




0
10/1/2003 3:31:11 PM
"Rod" <RodRodRodRod@hotmail.com> wrote:
> > Sorry, but I can't see any nonlinearity in the unknow parameters
> > A, ..., 2F. Where do you see them?
>
> large values of x, y, z contribute disproportionately

So what? The parameters are A, ..., F. And the paramter-depending
function that has to be fittet may even include e^x and 1/x. The
solution obtained using the qr decomposition is optimal in the 2-norm
sense.


> > And yes, parameter fitting is quite normal. Thousands of
> > people do it every day.
>
> I meant normal in the sense of Gaussian.

You started this "normal" thing. I used the word "typical" and you
disagreed with that.


> > And why do you want to make things more comlicated than they are?
>
> Because you may get a different answer, if the constraints are
violated then
> it maybe worth looking into.
> I agree LS will probably do the job, but as I don't know what the OP
is
> trying to achieve I provided the information so they could choose.

It will definitely do the job when one doesn't take the constraints into
account. Because from the original text, I thought the given intervals
were meant to be estimations rather than constraints. Maybe "tzavalas"
could tell us, wether he has "constraints" or "estimations" for the
parameters.


> > I'm not sure, because my statistics lectures are
> > far away, but I think a solution to maximum
> > likelihood estimation can be obtained by the
> > same algorithms? (I may be wrong in this point.)

> for y=a+bx and "normal" data it can.

Aha, that's always good to know. Thanks.

-- 
Andreas
For replying, remove the fruit from my address.


0
10/1/2003 3:44:17 PM
Andreas Keil wrote:
> Here comes the MatLab code, assuming you built the A matrix and b
vector
> as explained above.
>
> For applying the second (stable) method, use the following commands:
> % perform QR decomposition of A
> [Q R] = qr(A);
> % calculate solution of R x = Q^T b
> x = R\(Q'*b);
>
> The Matlab help to the QR algorithm proposes sth. based on a mixture
of
> the two methods which should also be very reliable:
> % perform QR decomposition of A
> [Q R] = qr(A);
> % calculate the solution of R^T R x (= A^T A x) = A^T b
> x = R\(R'\(A'*b));

> So, you only have to build the matrix A, vector b and enter two
command
> lines to obtain your solution x=(A,B,C,2D,2E,2F).
>
> The 2 methods normally are working equally reliable and are very fast
> and accurate. You could even use much more data samples then 323.
>
> If you want to check the accuracy, you can (in both cases) perform a
> correction step:
> % calculate residual
> r = b - A*x;
> % calculate error correction step (depending on which
> % method you prefer), which should be incredible small
> e = R\(Q'*b);
>    OR
> e = R\(R'\(A'*r));
> % add correction to solution vector
> x = x + e;

I discovered in the thread "minimization of complex argued function"
which is currently active in the group comp.soft-sys.matlab, that one
doesn't even have to perform the QR decomposition manually. The
commandline
x = A\b;
is already sufficient, since Matlab detects wether the system is
overdetermined or not and uses the QR or LR decomposition, respectively.
Great, isn't it?

-- 
Andreas
For replying, remove the fruit from my address.


0
10/1/2003 3:51:39 PM
In article <19203069.0310010328.59fa8ea4@posting.google.com>,
 tzabal@hotmail.com (tzavalas) writes:
 >Hello everybody, I'm a post-gratuate student from greece and since my
 >math and software knowledge is limited I seem to find it difficult to
 >solve the problem below.
 >
 >So this is the case:................
 >
 >After conducting an experiment I've collected some (323) values. 
 >
 >I know that those values come from the equation:
 >
 >value = A*x^2 + B*y^2 + C*z^2 + 2*D*x*y + 2*E*y*z + 2*F*z*x
 >
 >x, y and z are known and different for each value.
 >
 >My aim is to calculate the optimum values of A, B, C, D, E and F 
 >for which the values that will come up by the use of the equation will
 >be as close they can get to the experimental.
 >
 >I know for a fact that A,B and C are between 0-1 and D,E and F between
 >(-1)-1
 >
 >What I've done so far:..............
 >
 >x, y and z are limited numbers(mixed up cosines with sines and staff
 >like that)
 >
 >So I choose randomly a heaxad values for A-F and calculate the below
 >sum
 >
 >sum from i=1 to 323 ev(i)-value(equation)
 >
 >After that I choose a different hexad and calculate the new sum.
 >
 >Lets say, after 100 different hexads the one where the sum is minimum
 >is reported.
 >
 >This story continues for 100 times so from 100x100 sums I collect the
 >hexads of the 100 minimun.
 >
 >These hexads litim the values of A-F. For example the A of the ortimum
 >hexads is now between 0.2-0.5 etc...
 >
 >I rerun the same program having change the limits where A-F take their
 >random values.
 >
 >I keep doing this until I get variation of A-F value under the third
 >decomal
 >e.g. A [0.356 - 0.369]
 >
 >I want to know if there is a faster easier or more secure way to
 >calculate the optimum values of A-F.
 >
 >I used matlab to run the prementioned optimisation which is the only
 >one I know (I've learned it only to solve this problem) so if someone
 >has a set solution of a program for matlab ot would be much
 >appreciated.
 >
 >
 >I know it was to long a letter so even if you don't know the answer to
 >my problem I ought to thank you for your time.
 >
 >TIA spiros.

I assume you have x,y,z,value in vectors of length 323. 
so this is now vectorized:

A=[x.^2  2*x.*y 2*x.*z y.^2 2*y.*z z.^2 ] ;
b=value;
param=lsqlin(A,b,[],[],[],[],[0,-1,-1,0,-1,0],[1,1,1,1,1,1]);

if you have no access to the optimization toolbox and the bounds 
are not active then simply use
param=A\b;

hth
peter
0
spellucci (467)
10/1/2003 5:34:09 PM
"Andreas Keil" <andreas.keil@apple.nurfuerspam.de> wrote in message
news:blesoi$mv9$1@news-sop.inria.fr...
> "Rod" <RodRodRodRod@hotmail.com> wrote:
> > > Sorry, but I can't see any nonlinearity in the unknow parameters
> > > A, ..., 2F. Where do you see them?
> >
> > large values of x, y, z contribute disproportionately
>
> So what? The parameters are A, ..., F. And the paramter-depending
> function that has to be fittet may even include e^x and 1/x. The
> solution obtained using the qr decomposition is optimal in the 2-norm
> sense.


Sure you can solve the equations and get least sq aprox of A,B..., but this
is not necessarily the best estimation of the parameters. There are other
methods that will produce an estimation of the parameters with a lower
variance. In this particular problem we also know that the xyz's are trig
functions so the error terms certainly won't come from a normal
distribution.

And if the original poster is still with us, just get on and use the least
squares method and only worry about all this if you are not happy with the
result.




>
>
> > > And yes, parameter fitting is quite normal. Thousands of
> > > people do it every day.
> >
> > I meant normal in the sense of Gaussian.
>
> You started this "normal" thing. I used the word "typical" and you
> disagreed with that.
>



0
10/2/2003 8:13:39 AM
thank you all for the imediate responces and coments.

If only I knew about this google groups 6 months ago when I was trying
to find the answer to my problem.

Andreas I've sent you some e-mails cause its very difficult for me to
communicate instantly using google ( it takes at least 3 hours before
my posts are announced)

thanks again bye ,

spiros
0
tzabal (2)
10/2/2003 8:50:49 AM
-> This is a copy of my e-mail response, which I post, to keep the
others up to date. <-

> I'm sorry for intruding like this but it's the only way to get info
> in time since my messages in google are not reported earlier than 3
> hours from the minute I post them.
>
> By the way how did you managed to sent so many messages (and even
> have atype of conversation in one -only- day?????

If you access the Usenet (that's how the usegroup network is called) via
Google, it's of course very slow, because Google is more like an archive
for the Usenet. They collect and store all messages so that you can
perform searches on them (even after 10 years, sometimes).
I would suggest, that you find a news server, which you can use to acces
the newsgroups directly. In this way, you will see new messages just
after a few seconds normally and it's more comfortable, since you can
use Outlook Express (not Outlook, unfortunately), Netscape Messenger or
whatever for reading and writing messages just like e-mails. (I assume,
that you are a Windows user, right?)
How to find a news server? Normally your ISP (Internet Service Provider)
provides such a thing. It's name is maybe sth. like news-yourisp.com.
You have to search for it on your ISP's website. Alternatively, you can
try to find a free server on the internet. I know one such server, see
news.individual.net. I never tried it, but it seems to be great. It's
run by a German university. They require some short registration, but
I'm sure, they will never use your data for commercial purposes.
After having found such a server, you have to configure your news reader
/ client (e.g. Outlook Express) with the name of the news server. You
can have a look at news.individual.net where they have instructions, how
to configure Outlook Express.
After that, you get a list of available newsgroups and you have to
choose, which of them you want to read. That's it.

> If I got it right: A is a 323X6 matrix of arrays x^2, y^2...  (just
> checking)
>
> and b is a 323X1 matrix of the corresponding experimental values??

Perfectly right.

> Is this what I have to run in matlab??? :
>
> ===========================
> % perform QR decomposition of A
> [Q R] = qr(A);
> % calculate solution of R x = Q^T b
> x = R\(Q'*b);
> ==========================

Yes, except that you can skip the lines starting with '%', since those
are comments.

> what " R x" is???? Is it R*x or just a symbolism " R x"
> also what " Q^T b " is? Is it Q^T*b

You found "R x" in the LaTeX part, right? It's just a product of matrix
R and vector x. That's math notation (omitting the multiplication dot),
but you have to use "R*x" in MatLab. You should run LaTeX to see the
LaTeX part more clearly. For the case that you don't have MatLab, I
attached the pdf file created from the code. (I didn't attach it in the
news, however.)

> What is Q, T and R matrices or just values???
> (I guess Q is certainly a matrix)

Q and R are matrices, which are given back from the "qr" function by the
statement "[Q R] = qr(A)". Q^T means "Q transposed". LaTeX sets the "^T"
as a superscript. See the attached pdf file.

> what " R\(Q'*b) " stands for???

This is MatLab notation for:
"solve the linear equation system R*x = Q'*b", where Q' is the transpose
of Q in Matlab notation.

> is there somewhere a  * or \ which stands for element to element
> multiplication or division???

There were no element by element multiplications or divisions.

> Do I have to input values for Q, T and R or the program itself does
> it???

T is no matrix, as I said, it's just the transpose. And Q and R are
output of the qr decomposition. So, you only have to enter A and b.

> What about??? :
> ==========================
> % perform QR decomposition of A
> [Q R] = qr(A);
> % calculate the solution of R^T R x (= A^T A x) = A^T b
> x = R\(R'\(A'*b));
> ============================
>
> Is it just a second method to check the first?????

Exaclty. I think you can forget about it. It's essentially the same.

> I know that my question maybe sound childish but -as I have reported-
> my backgruond on programing is extremely limited.
> Thank you for your time.
> I'm looking forward hearing from you, bye, spiros

And now, attention: Up to yesterday, I didn't know, that it's even
easier in MatLab to solve your overdetermined equation system in the
following way:
1. Enter A and b as above.
2. Enter the line "x = A\b" (without quotes) in MatLab.
Thats it. x contains your parameters.
The reason that you don't have to do the qr decomposition anymore is,
that MatLab automatically recognizes that the system is overdetermined
and therefore performs the qr factorization automatically. Great, isn't
it?

One final note: I would use a slightly modified data matrix A, like
Peter Boettcher proposed it in his response. The only difference is,
that you put your 2's into the data matrix A instead of the parameter
vector x, so you get (A, B, C, D, E, F) as entries in x. I already
updated the PDF file to represent the change.

Peter Spelluci gave you some hints how to produce the BIG matrix A very
fast, assuming you already stored x, y, z in vectors. (Don't enter A
manually, that's too much work!) But be aware that he slightly changed
the column order.

I think, that's it. Go and get your news server immediately! Google is
good for searching their archives, but that's it.

-- 
Andreas
For replying, remove the fruit from my address.


0
10/2/2003 9:03:41 AM
Reply: