Thank you Chris.
I would rather suspect a bug in the cov_table() function, based on your
answer.
cov_table is a function that computes covariance matrix (transposed). To
use it, you have to do : use PDL::Stats
If PDL::Stats is installed on your machine, you will be able to
reproduce the bug.
Thanx again for your help.
Stéphane
Le 10/06/2011 12:57, chm a écrit :
Hi-
I can't reproduce this problem since I'm
not familiar with the cov_table() routine
(at least it doesn't show up on my PDL
install). See BUGS from the PDL distribution
or at
http://cpansearch.perl.org/src/CHM/PDL-2.4.9/BUGS
for some additional information that you'll
need to include for better diagnosis and
help with problems. Some possibilities that
come to mind are:
(1) Multiple variables of the same name
where the lexical one might be "hiding"
the other expected value. Compiling
with 'use strict;' might help catch
these.
(2) Dataflow is changing data in unexpected
ways (i.e., withing the cov_table() call)
(3) Bug in the inv() routine. A number of
issues were addressed in the latest
PDL-2.4.9 release. Which PDL version
are you using? You could check against
the matinv() routine from PDL::Slatec.
If you are using an old version of PDL, I
suggest upgrading to the current release.
There have been many bugs fixed and some
very nice feature and usability improvements
over the last year.
Cheers,
Chris
On 6/10/2011 5:54 AM, Stéphane Lévy wrote:
Hello,
I have found unexpected, astonishing results using the PDL matrix inv()
function by 2 different ways.
In the first way I manipulate PDL objects all the way, in the second way
I recreate objects by pasting values of the original PDL object into a
new PDL object.
First way gives unexpected, wrong result, second way leads to accurate
result. I do not understand this and it worries me a bit as I am
supposed to use intensively PDL matrix functions.
Anybody can give me an explanation of this, and tell me what I should do
differently when I manipulate objects?
Here is what I did :
# step 1A : creating a (2,2) matrix
Perl> my $m = random(2,2)
$PDL1 =
[
[0.65707276 0.12124598]
[0.95303134 0.43850649]
]
;
# step 1B : computing cov table of the matrix
Perl> my $c = $m->cov_table()
$PDL1 =
[
[0.071777584 0.068924048]
[0.068924048 0.066183954]
]
;
# step 1C : testing if the the matrix multiplied by its inverse is equal
to identity matrix
Perl> $c x inv($c)
$PDL1 =
[
[ 1 0]
[-0.125 1.125]
]
;
# we observe that step 1C leads to unexpected result
# step 2A : pasting the content of PDL obtained in step 1B to a new PDL
object : the 2 PDL objects are supposedly perfectly identical
Perl> $m = pdl([0.071777584,0.068924048],[0.068924048,0.066183954])
$PDL1 =
[
[0.071777584 0.068924048]
[0.068924048 0.066183954]
]
;
# step 2B : same as step 1C, testing if the the matrix multiplied by its
inverse is equal to identity matrix
Perl> $m x $m->inv()
$PDL1 =
[
[1 0]
[0 1]
]
;
# we observe that step 2B leads to expected result
Thank you.
Best regards.
Stéphane
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl