stdv
Signature: (a(n); float+ [o]b())
Sample standard deviation.
stdv processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for
any of the input ndarrays.
stdv_unbiased
Signature: (a(n); float+ [o]b())
Unbiased estimate of population standard deviation.
stdv_unbiased processes bad values. It will set the bad-value flag of all output ndarrays if the flag is
set for any of the input ndarrays.
var
Signature: (a(n); float+ [o]b())
Sample variance.
var processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for
any of the input ndarrays.
var_unbiased
Signature: (a(n); float+ [o]b())
Unbiased estimate of population variance.
var_unbiased processes bad values. It will set the bad-value flag of all output ndarrays if the flag is
set for any of the input ndarrays.
se
Signature: (a(n); float+ [o]b())
Standard error of the mean. Useful for calculating confidence intervals.
# 95% confidence interval for samples with large N
$ci_95_upper = $data->average + 1.96 * $data->se;
$ci_95_lower = $data->average - 1.96 * $data->se;
se processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for
any of the input ndarrays.
ss
Signature: (a(n); float+ [o]b())
Sum of squared deviations from the mean.
ss processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for
any of the input ndarrays.
skew
Signature: (a(n); float+ [o]b())
Sample skewness, measure of asymmetry in data. skewness == 0 for normal distribution.
skew processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for
any of the input ndarrays.
skew_unbiased
Signature: (a(n); float+ [o]b())
Unbiased estimate of population skewness. This is the number in GNumeric Descriptive Statistics.
skew_unbiased processes bad values. It will set the bad-value flag of all output ndarrays if the flag is
set for any of the input ndarrays.
kurt
Signature: (a(n); float+ [o]b())
Sample kurtosis, measure of "peakedness" of data. kurtosis == 0 for normal distribution.
kurt processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for
any of the input ndarrays.
kurt_unbiased
Signature: (a(n); float+ [o]b())
Unbiased estimate of population kurtosis. This is the number in GNumeric Descriptive Statistics.
kurt_unbiased processes bad values. It will set the bad-value flag of all output ndarrays if the flag is
set for any of the input ndarrays.
cov
Signature: (a(n); b(n); float+ [o]c())
Sample covariance. see corr for ways to call
cov processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for
any of the input ndarrays.
cov_table
Signature: (a(n,m); float+ [o]c(m,m))
Square covariance table. Gives the same result as threading using cov but it calculates only half the
square, hence much faster. And it is easier to use with higher dimension pdls.
Usage:
# 5 obs x 3 var, 2 such data tables
perldl> $a = random 5, 3, 2
perldl> p $cov = $a->cov_table
[
[
[ 8.9636438 -1.8624472 -1.2416588]
[-1.8624472 14.341514 -1.4245366]
[-1.2416588 -1.4245366 9.8690655]
]
[
[ 10.32644 -0.31311789 -0.95643674]
[-0.31311789 15.051779 -7.2759577]
[-0.95643674 -7.2759577 5.4465141]
]
]
# diagonal elements of the cov table are the variances
perldl> p $a->var
[
[ 8.9636438 14.341514 9.8690655]
[ 10.32644 15.051779 5.4465141]
]
for the same cov matrix table using cov,
perldl> p $a->dummy(2)->cov($a->dummy(1))
cov_table processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set
for any of the input ndarrays.
corr
Signature: (a(n); b(n); float+ [o]c())
Pearson correlation coefficient. r = cov(X,Y) / (stdv(X) * stdv(Y)).
Usage:
perldl> $a = random 5, 3
perldl> $b = sequence 5,3
perldl> p $a->corr($b)
[0.20934208 0.30949881 0.26713007]
for square corr table
perldl> p $a->corr($a->dummy(1))
[
[ 1 -0.41995259 -0.029301192]
[ -0.41995259 1 -0.61927619]
[-0.029301192 -0.61927619 1]
]
but it is easier and faster to use corr_table.
corr processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set for
any of the input ndarrays.
corr_table
Signature: (a(n,m); float+ [o]c(m,m))
Square Pearson correlation table. Gives the same result as threading using corr but it calculates only
half the square, hence much faster. And it is easier to use with higher dimension pdls.
Usage:
# 5 obs x 3 var, 2 such data tables
perldl> $a = random 5, 3, 2
perldl> p $a->corr_table
[
[
[ 1 -0.69835951 -0.18549048]
[-0.69835951 1 0.72481605]
[-0.18549048 0.72481605 1]
]
[
[ 1 0.82722569 -0.71779883]
[ 0.82722569 1 -0.63938828]
[-0.71779883 -0.63938828 1]
]
]
for the same result using corr,
perldl> p $a->dummy(2)->corr($a->dummy(1))
This is also how to use t_corr and n_pair with such a table.
corr_table processes bad values. It will set the bad-value flag of all output ndarrays if the flag is
set for any of the input ndarrays.
t_corr
Signature: (r(); n(); [o]t())
$corr = $data->corr( $data->dummy(1) );
$n = $data->n_pair( $data->dummy(1) );
$t_corr = $corr->t_corr( $n );
use PDL::GSL::CDF;
$p_2tail = 2 * (1 - gsl_cdf_tdist_P( $t_corr->abs, $n-2 ));
t significance test for Pearson correlations.
t_corr processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set
for any of the input ndarrays.
n_pair
Signature: (a(n); b(n); indx [o]c())
Returns the number of good pairs between 2 lists. Useful with corr (esp. when bad values are involved)
n_pair processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set
for any of the input ndarrays.
corr_dev
Signature: (a(n); b(n); float+ [o]c())
$corr = $a->dev_m->corr_dev($b->dev_m);
Calculates correlations from dev_m vals. Seems faster than doing corr from original vals when data pdl is
big
corr_dev processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set
for any of the input ndarrays.
t_test
Signature: (a(n); b(m); float+ [o]t(); [o]d())
my ($t, $df) = t_test( $pdl1, $pdl2 );
use PDL::GSL::CDF;
my $p_2tail = 2 * (1 - gsl_cdf_tdist_P( $t->abs, $df ));
Independent sample t-test, assuming equal var.
t_test processes bad values. It will set the bad-value flag of all output ndarrays if the flag is set
for any of the input ndarrays.
t_test_nev
Signature: (a(n); b(m); float+ [o]t(); [o]d())
Independent sample t-test, NOT assuming equal var. ie Welch two sample t test. Df follows Welch-
Satterthwaite equation instead of Satterthwaite (1946, as cited by Hays, 1994, 5th ed.). It matches
GNumeric, which matches R.
my ($t, $df) = $pdl1->t_test( $pdl2 );
t_test_nev processes bad values. It will set the bad-value flag of all output ndarrays if the flag is
set for any of the input ndarrays.
t_test_paired
Signature: (a(n); b(n); float+ [o]t(); [o]d())
Paired sample t-test.
t_test_paired processes bad values. It will set the bad-value flag of all output ndarrays if the flag is
set for any of the input ndarrays.
binomial_test
Signature: (x(); n(); p_expected(); [o]p())
Binomial test. One-tailed significance test for two-outcome distribution. Given the number of successes,
the number of trials, and the expected probability of success, returns the probability of getting this
many or more successes.
This function does NOT currently support bad value in the number of successes.
Usage:
# assume a fair coin, ie. 0.5 probablity of getting heads
# test whether getting 8 heads out of 10 coin flips is unusual
my $p = binomial_test( 8, 10, 0.5 ); # 0.0107421875. Yes it is unusual.