I want to compute covariance using PDL, but the problem is that it always shows an error:
Undefined subroutine &main::cov called at line 12.
Can anyone tell me where I’m making a mistake?
#! usr/bin/perl
use strict;
use warnings;
use PDL;
my $a = random(5, 3);
my $b = random(5, 3);
print "$a\n$b\n";
my $cov = cov($a, $b); #line 12
print "$cov\n";
That error message tells you that a function named
covis not exported by default byPDL. If I search the PDL CPAN page (using thegreptool), I do not see a function namedcov.A google search yields PDL::Stats::Basic, which has a
covfunction.