Fwd: Re: Question about JAMA
- Subject: Fwd: Re: Question about JAMA
- From: boisvert@nist.gov
- Date: Wed, 10 Oct 2007 08:36:14 -0400
- Content-Type: multipart/mixed; boundary="-MOQ1192019774095a7882d6058fe32f3d6d0330427f8e"
- User-Agent: Internet Messaging Program (IMP) 3.2.1
----- Forwarded message from Zeb Tate <zebtate@ieee.org> -----
Date: Wed, 10 Oct 2007 01:27:55 -0400
From: Zeb Tate <zebtate@ieee.org>
Reply-To: zebtate@ieee.org
Subject: Re: Question about JAMA
To: boisvert@nist.gov
If you have an overdetermined system (where there are more rows than
columns), there usually isn't a unique solution for x, so you'll have to
impose further constraints on the solution vector x. The most common
constraint is to find the x so that ||A*x - b|| is minimized, where || || is
the Euclidean norm (more information on this is available at
http://en.wikipedia.org/wiki/Linear_least_squares). Luckily, JAMA will do
this for you (see the javadoc for the Matrix.solve method). Here's some
example code to get JAMA to solve the minimum least squares solution to Ax=b
for an A matrix with 3 rows and 2 columns:
double[] Avals = {1.0,1.0,1.0,2.0,3.0,4.0};
Matrix A = new Matrix(Avals , 3);
double[] bvals = {1.0,5.0,7.0};
Matrix b = new Matrix(bvals,3);
Matrix x = A.solve(b);
-Zeb Tate
On 10/9/07, boisvert@nist.gov <boisvert@nist.gov> wrote:
>
>
>
> ----- Forwarded message from Justinas.Greibus@sonex.lt -----
> Date: Tue, 9 Oct 2007 05:05:36 -0400
> From: Justinas.Greibus@sonex.lt
> Reply-To: Justinas.Greibus@sonex.lt
> Subject: Question about JAMA
> To: boisvert@nist.gov
>
> logo.JPG
>
>
>
> Hi,
>
>
>
> I want to ask you about java package JAMA and to try to solve my problem.
> I'm
> trying to compute my computer position using data from wireless access
> points.
> For it, I need to solve Ax=b equation and I founded that its possible to
> do
> with yours java package JAMA. But here is one problem, the A matrix in my
> equation isn't square matrix (it has two columns and four rows) and b
> matrix
> has one column and four rows. So, i want to know if its possible to find x
> using yours package JAMA and if its possible to do, please write me answer
> and
> the example.
>
>
>
> Thank you very much
>
>
>
>
>
>
>
> Pagarbiai
>
>
>
> Justinas Greibus
>
> Testuotojas
>
>
> cid:image002.gif@01C7FEAB.3BBB1E90
>
> UAB „Sonex Technologies"
> Savanoriø pr. 178A,
>
> LT- 44150 Kaunas
>
>
> cid:image003.gif@01C7FEAB.3BBB1E90
>
> Mob. (689) 15025
>
>
> cid: image004.gif@01C7FEAB.3BBB1E90
>
> El.p. <mailto:jusgre@sonex.lt> jusgre@sonex.lt
>
> <http://www.sonex.lt> www.sonex.lt
>
>
>
>
> ----- End forwarded message -----
>
>
>
>
----- End forwarded message -----
If you have an overdetermined system (where there are more rows than columns), there usually isn't a unique solution for x, so you'll have to impose further constraints on the solution vector x. The most common constraint is to find the x so that ||A*x - b|| is minimized, where || || is the Euclidean norm (more information on this is available at
http://en.wikipedia.org/wiki/Linear_least_squares). Luckily, JAMA will do this for you (see the javadoc for the Matrix.solve method). Here's some example code to get JAMA to solve the minimum least squares solution to Ax=b for an A matrix with 3 rows and 2 columns:
double[] Avals = {1.0,1.0,1.0,2.0,3.0,4.0};
Matrix A = new Matrix(Avals , 3);
double[] bvals = {1.0,5.0,7.0};
Matrix b = new Matrix(bvals,3);
Matrix x = A.solve(b);
-Zeb Tate
Date Index |
Thread Index |
Problems or questions? Contact list-master@nist.gov