COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### optimization #2 789967

• Email
• Follow

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

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
Reply tzabal (2) 10/1/2003 11:28:35 AM

See related articles to this posting

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

--
Andreas


 0
Reply andreas.keil (30) 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
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


 0
Reply andreas.keil (30) 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
> 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
>
>


 0
Reply RodRodRodRod (4) 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


 0
Reply andreas.keil (30) 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
Reply boettcher (2302) 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
Reply RodRodRodRod (4) 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


 0
Reply andreas.keil (30) 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


 0
Reply andreas.keil (30) 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
>
>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
Reply spellucci (466) 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
Reply RodRodRodRod (4) 10/2/2003 8:13:39 AM

thank you all for the imediate responces and coments.

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
Reply 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

> 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.

> ==========================
> % 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


 0
Reply andreas.keil (30) 10/2/2003 9:03:41 AM

12 Replies
106 Views

Similar Articles

12/9/2013 11:43:51 PM
[PageSpeed]

Similar Artilces:

optimization within optimization problem
I have a 60 month data sample of bond prices. For each month I am trying to extract the interest rates of the month (term structure) from the bond prices using an optimization problem consequenly, for i=1:60 x =fmincon(@(x)NS3(x,Qtc),par0,A,B,[],[],lb,ub,@(x)myconstrTR(x),options); %% x are the parameteres of the term structure model , which means that : interest=NS4(time,x) end % the problem that I am facing is the following. I know the average interest rate of the 5 year period as derived by another research paper (let us call them Y). This means I know the average of the 60 months. Is there a way to have another optimization problem that says if the average interest of the 60 monrths is different than those of Y then redo the computations of the months 1:60 till the average interest converges to those of Y? "joseph Frank" <josephfrank1969@hotmail.com> wrote in message <i4u5un$m8u$1@fred.mathworks.com>... > I have a 60 month data sample of bond prices. For each month I am trying to extract the interest rates of the month (term structure) from the bond prices using an optimization problem > > consequenly, > >

Java optimization.
even though value may not be used, the action of Integer.parseInt may have some side effects. Suppose str is set to be "dw23f~~"? The value of str would have to be known (or limited in some form) and the semantics of Integer.parseInt would have to be guaranteed to not throw an exception.One can argue that the call related to the assignment of the value should be optimized as well, but some assignments for unused variables may be purposeful in effect.I can't see how the optimization would avoid violating the JLS in these circumstances without requiring serious in-depth analysis

optimization #9
Hi all, I just started using 'matlab' and would like to know how to use optimization function. I have a simple series of differential equations. for example, (d/dt) X = - a*X*Y (d/dt) Y = + a*X*Y - b*Y (d/dt) Z = + b*Y And I have a data of Y over several time points. So I have the objective function that is intended to calculate the difference between the model generated value and the data. Now I want to estimate the 'a' from the above equation by minimizing the objective function. I am wondering how we implement those procedure in 'matlab'. Even just a simple advice will be greatly appreciated. Thank you very much.

database optimization
Hi We use Sql 2000. When defining a database maintenance plan one of the options is to optimize the database, reorganize data and index pages, remove unused pages etc. Is there a command to do this manualy (or in a job) and not by usung a DBM plan ? "David Greenberg" <davidgr@iba.org.il> wrote in message news:flaupm$35v$1@news2.netvision.net.il... > Hi > We use Sql 2000. > When defining a database maintenance plan one of the options is to > optimize the database, reorganize data and index pages, remove unused > pages etc. > Is there a command to do this

fmincon optimization
Hi, In my fmincon optimization of 2 control variables and 3 state variables I would like to keep one of the optimized control variables fixed for several loops, while the other control variable is still optimized in each loop. To be more specific, say the control vars are A and B and the state vars are x,y,z. Then: for x=1:X for y=1:Y for z=1:Z A(x,y,z) = ... B(x,y,(z?)) = ... end end end Let's say z=years: if z=2 I want A to be optimized in z=1 and keep it fixed during z=1 and z=2. If z=3 I want A to be fixed during z=1, z=2, z=3. Etc. But, at the same time I want B to be optimized in each year, so in z=1, z=2, z=3 etc. So far I have been able to fix A for z-years, by looping A over z. I haven't been able to figure out, however, how to let B loop over z as well, without fixing it for z-years. Is there a way to implement this in a loop or maybe through an equality constraint in the fmincon optimization? Any suggestion on how to implement this is appreciated! Diana

optimization problem
Hi, how can I solve this optimization problem? min f(x1,x2) 0<g1(x1,x2)<a1 0<g2(x1,x2)<a2 It's possible using matlab? Thanks, Aurel On 12 Dec 2003 15:56:37 -0800, aurtoma@tin.it (aurel) wrote: >how can I solve this optimization problem? > min f(x1,x2) > 0<g1(x1,x2)<a1 > 0<g2(x1,x2)<a2 >It's possible using matlab? What I would do is build a fitness function like this: Fitness = -f(x1,x2) - K1*[(error1) + (error2)], where error1 and error2 are, respectively, the absolute values of the amounts by which g1 and g2 violate... this optimization problem? > > min f(x1,x2) > > 0<g1(x1,x2)<a1 > > 0<g2(x1,x2)<a2 > >It's possible using matlab? > > What I would do is build a fitness function like this: > > Fitness = -f(x1,x2) - K1*[(error1) + (error2)], > > where error1 and error2 are, respectively, the absolute values of the > amounts by which g1 and g2 violate the constraints. During the > evolution of x1 and x2 in search of min(f), I would start with K1 > small and gradually increase it to a very high value, so that at the > end, even for fairly

Memory Optimization
This is a multi-part message in MIME format. ------=_NextPart_000_00D4_01C5FCEB.FD4CF380 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hey, Other than saving the memory space, does anyone has any idea "when and why" Zero-Fill-On-Demand (ZFOD) is an anti-optimization for Minix? Also, why is it that Minix does not contain the environment variables in the executable files? Instead, the user library needs to build the complete stack image and copied to a buffer, before passing to the new core image. Thank you for the help...:none'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt;font-family:"Courier New"'>Other than saving = the memory space, does anyone has any idea &#8220;when and why&#8221; = Zero-Fill-On-Demand (ZFOD) is an anti-optimization for Minix?<o:p></o:p></span></font></p> <p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 = face=3D"Courier New"><span style=3D'font-size:10.0pt;font-family:"Courier = New"'><o:p>&nbsp;</o

Simulation Optimization
Hi, I am trying to solve a simulation optimization problem with the following characteristics: 1. Objective function is calculated based on an external simulation program. 2. The simulator is highly nonlinear in the variables. 3. Simulator runs are costly as well as noisy (hence gradient estimates are likely to be unreliable). 4. The number of variables is small (~60), but may rise significantly in the future (to the thousands). 5. The only constraints on the optimization are bounds on the variables. I am currently testing the Pattern Search algorithm in the Genetic Algorithm and Direct Search toolbox. Are there any other functions in Matlab (or elsewhere) that might fit this kind of problem? thanks, Rama In article <1107352407.314129.146840@o13g2000cwo.googlegroups.com>, "Ramachandran Balakrishna" <rama.balakrishna@gmail.com> writes: >Hi, > >I am trying to solve a simulation optimization problem with the >following characteristics: > >1. Objective function is calculated based on an external simulation >program. >2. The simulator is highly nonlinear in the variables. >3. Simulator runs are costly as well as noisy

Optimization order
Hi, Do You Know Of Any Guidelines In Which Order Standard Compiler Optimizations Should Be Invoked Promising Best Run-Time Results? Probably, the order will vary from compiler to compiler due to different implementations of the optimizations, but still I can imagine that some types of optimizations might profit from other optimization classes that should be invoked before. Best regards, Christian Muchnick's "Advanced compiler design and implementation" has a recommended order of optimizations. Other books give hints but not always a complete picture. K.Phillips Stephan, > Do You Know Of Any Guidelines In Which Order Standard Compiler > Optimizations Should Be Invoked Promising Best Run-Time Results? > > Probably, the order will vary from compiler to compiler due to > different implementations of the optimizations, but still I can > imagine that some types of optimizations might profit from other > optimization classes that should be invoked before. These days the bleeding edge of compiler optimization uses some form of machine learning to select the best ordering for a given program. A Google search using the terms: compiler optimizing

Existence of solution to an optimization problem?
Hi, I want to show that there exist a solution with zero value to the following optimization problem: min norm(Ax-b)^2 s.t. 0<=x_{i}<=1 where A=[0 1 1 0 0 0 1 1; 0 1 0 1 0 1 0 1; 0 1 0 1 1 0 1 0; 1 1 1 1 1 1 1 1] and b=[rand;rand;rand;1], here "rand" denotes a value between 0 and 1 (like in Matlab). i.e., Does there exist a 8x1 vector, x such that its entires are between 0 and 1 and it satisfies Ax=b? How can I show this? Any suggestions?