You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
is( tapprox( $a->cov($b), 0.6 ), 1, "sample covariance of $a and $b" );
57
-
is( tapprox( $a->corr($b), 0.866025403784439 ), 1, "Pearson correlation coefficient of $a and $b");
58
-
is( tapprox( $a->n_pair($b), 5 ), 1, "Number of good pairs between $a and $b");
59
-
is( tapprox( $a->corr($b)->t_corr( 5 ), 3 ), 1, "t significance test of Pearson correlation coefficient of $a and $b");
60
-
is( tapprox( $a->corr_dev($b), 0.903696114115064 ), 1, "correlation calculated from dev_m values of $a and $b");
61
-
62
-
my$b_bad = sequence 6;
63
-
$b_bad = qsort( $b_bad % 2 );
64
-
$b_bad->setbadat(0);
65
-
66
-
is( tapprox( $a_bad->cov($b_bad), 0.5 ), 1, "sample covariance with bad data of $a_bad and $b_bad");
67
-
is( tapprox( $a_bad->corr($b_bad), 0.894427190999916 ), 1, "Pearson correlation coefficient with bad data of $a_bad and $b_bad");
68
-
is( tapprox( $a_bad->n_pair($b_bad), 4 ), 1, "Number of good pairs between $a_bad and $b_bad with bad values taken into account");
69
-
is( tapprox( $a_bad->corr($b_bad)->t_corr( 4 ), 2.82842712474619 ), 1, "t signifiance test of Pearson correlation coefficient with bad data of $a_bad and $b_bad");
70
-
is( tapprox( $a_bad->corr_dev($b_bad), 0.903696114115064 ), 1, "correlation calculated from dev_m values with bad data of $a_bad and $b_bad");
29
+
is_pdl $a_bad->stdv, pdl( 1.4142135623731 ), "standard deviation of $a_bad";
30
+
is_pdl $a_bad->stdv_unbiased, pdl( 1.58113883008419 ), "unbiased standard deviation of $a_bad";
31
+
is_pdl $a_bad->var, pdl( 2 ), "variance of $a_bad";
32
+
is_pdl $a_bad->var_unbiased, pdl( 2.5 ), "unbiased variance of $a_bad";
33
+
is_pdl $a_bad->se, pdl( 0.707106781186548 ), "standard error of $a_bad";
34
+
is_pdl $a_bad->ss, pdl( 10 ), "sum of squared deviations from the mean of $a_bad";
35
+
is_pdl $a_bad->skew, pdl( 0 ), "sample skewness of $a_bad";
36
+
is_pdl $a_bad->skew_unbiased, pdl( 0 ), "unbiased sample skewness of $a_bad";
37
+
is_pdl $a_bad->kurt, pdl( -1.3 ), "sample kurtosis of $a_bad";
38
+
is_pdl $a_bad->kurt_unbiased, pdl( -1.2 ), "unbiased sample kurtosis of $a_bad";
39
+
40
+
my$b = pdl '0 0 0 1 1';
41
+
is_pdl $a->cov($b), pdl( 0.6 ), "sample covariance of $a and $b";
42
+
is_pdl $a->corr($b), pdl( 0.866025403784439 ), "Pearson correlation coefficient of $a and $b";
43
+
is_pdl $a->n_pair($b), indx( 5 ), "Number of good pairs between $a and $b";
44
+
is_pdl $a->corr($b)->t_corr( 5 ), pdl( 3 ), "t significance test of Pearson correlation coefficient of $a and $b";
45
+
is_pdl $a->corr_dev($b), pdl( 0.903696114115064 ), "correlation calculated from dev_m values of $a and $b";
46
+
47
+
my$b_bad = pdl 'BAD 0 0 1 1 1';
48
+
is_pdl $a_bad->cov($b_bad), pdl( 0.5 ), "sample covariance with bad data of $a_bad and $b_bad";
49
+
is_pdl $a_bad->corr($b_bad), pdl( 0.894427190999916 ), "Pearson correlation coefficient with bad data of $a_bad and $b_bad";
50
+
is_pdl $a_bad->n_pair($b_bad), indx( 4 ), "Number of good pairs between $a_bad and $b_bad with bad values taken into account";
51
+
is_pdl $a_bad->corr($b_bad)->t_corr( 4 ), pdl( 2.82842712474619 ), "t signifiance test of Pearson correlation coefficient with bad data of $a_bad and $b_bad";
52
+
is_pdl $a_bad->corr_dev($b_bad), pdl( 0.903696114115064 ), "correlation calculated from dev_m values with bad data of $a_bad and $b_bad";
71
53
72
54
my ($t, $df) = $a->t_test($b);
73
-
is( tapprox( $t, 2.1380899352994 ), 1, "t-test between $a and $b - 't' output");
74
-
is( tapprox( $df, 8 ), 1, "t-test between $a and $b - 'df' output");
55
+
is_pdl $t, pdl( 2.1380899352994 ), "t-test between $a and $b - 't' output";
56
+
is_pdl $df, pdl( 8 ), "t-test between $a and $b - 'df' output";
75
57
76
58
($t, $df) = $a->t_test_nev($b);
77
-
is( tapprox( $t, 2.1380899352994 ), 1, "t-test with non-equal variance between $a and $b - 't' output");
78
-
is( tapprox( $df, 4.94637223974763 ), 1, "t-test with non-equal variance between $a and $b - 'df' output");
59
+
is_pdl $t, pdl( 2.1380899352994 ), "t-test with non-equal variance between $a and $b - 't' output";
60
+
is_pdl $df, pdl( 4.94637223974763 ), "t-test with non-equal variance between $a and $b - 'df' output";
79
61
80
62
($t, $df) = $a->t_test_paired($b);
81
-
is( tapprox( $t, 3.13785816221094 ), 1, "paired sample t-test between $a and $b - 't' output");
82
-
is( tapprox( $df, 4 ), 1, "paired sample t-test between $a and $b - 'df' output");
63
+
is_pdl $t, pdl( 3.13785816221094 ), "paired sample t-test between $a and $b - 't' output";
64
+
is_pdl $df, pdl( 4 ), "paired sample t-test between $a and $b - 'df' output";
83
65
84
66
($t, $df) = $a_bad->t_test($b_bad);
85
-
is( tapprox( $t, 1.87082869338697 ), 1, "t-test with bad values between $a_bad and $b_bad - 't' output");
86
-
is( tapprox( $df, 8 ), 1, "t-test with bad values between $a_bad and $b_bad - 'd' output");
67
+
is_pdl $t, pdl( 1.87082869338697 ), "t-test with bad values between $a_bad and $b_bad - 't' output";
68
+
is_pdl $df, pdl( 8 ), "t-test with bad values between $a_bad and $b_bad - 'd' output";
87
69
88
70
($t, $df) = $a_bad->t_test_nev($b_bad);
89
-
is( tapprox( $t, 1.87082869338697 ), 1, "t-test with non-equal variance with bad values between $a_bad and $b_bad - 't' output");
90
-
is( tapprox( $df, 4.94637223974763 ), 1, "t-test with non-equal variance with bad values between $a_bad and $b_bad - 'df' output");
71
+
is_pdl $t, pdl( 1.87082869338697 ), "t-test with non-equal variance with bad values between $a_bad and $b_bad - 't' output";
72
+
is_pdl $df, pdl( 4.94637223974763 ), "t-test with non-equal variance with bad values between $a_bad and $b_bad - 'df' output";
91
73
92
74
($t, $df) = $a_bad->t_test_paired($b_bad);
93
-
is( tapprox( $t, 4.89897948556636 ), 1, "paired sample t-test with bad values between $a_bad and $b_bad - 't' output");
94
-
is( tapprox( $df, 3 ), 1, "paired sample t-test with bad values between $a_bad and $b_bad - 'df' output");
75
+
is_pdl $t, pdl( 4.89897948556636 ), "paired sample t-test with bad values between $a_bad and $b_bad - 't' output";
76
+
is_pdl $df, pdl( 3 ), "paired sample t-test with bad values between $a_bad and $b_bad - 'df' output";
ok PDL::Core::approx( $stdv, 1.01980390271856 ) || PDL::Core::approx( $stdv, 1.16619037896906 ), "fill_rand replaces bad values with random sample of good values from same variable";
34
15
}
35
16
36
-
ok tapprox( $a->dev_m->avg, 0 ), "dev_m replaces values with deviations from the mean on $a";
37
-
ok tapprox( $a->stddz->avg, 0 ), "stddz standardizes data on $a";
17
+
my$a = sequence 5;
18
+
is_pdl $a->dev_m, pdl('-2 -1 0 1 2'), "dev_m replaces values with deviations from the mean on $a";
19
+
is_pdl $a->stddz, pdl('-1.41421356237309 -0.707106781186547 0 0.707106781186547 1.41421356237309'), "stddz standardizes data on $a";
38
20
39
-
ok tapprox( $a->sse($b), 18), "sse gives sum of squared errors between actual and predicted values between $a and $b";
40
-
ok tapprox( $a->mse($b), 3.6), "mse gives mean of squared errors between actual and predicted values between $a and $b";
41
-
ok tapprox( $a->rmse($b), 1.89736659610103 ), "rmse gives root mean squared error, ie. stdv around predicted value between $a and $b";
21
+
my$b = pdl(0, 0, 0, 1, 1);
22
+
is_pdl $a->sse($b), pdl(18), "sse gives sum of squared errors between actual and predicted values between $a and $b";
23
+
is_pdl $a->mse($b), pdl(3.6), "mse gives mean of squared errors between actual and predicted values between $a and $b";
24
+
is_pdl $a->rmse($b), pdl(1.89736659610103), "rmse gives root mean squared error, ie. stdv around predicted value between $a and $b";
42
25
43
-
ok tapprox( $b->glue(1,ones(5))->pred_logistic(pdl(1,2))->sum, 4.54753948757851 ), "pred_logistic calculates predicted probability value for logistic regression";
26
+
is_pdl $b->glue(1,ones(5))->pred_logistic(pdl(1,2)), pdl('0.880797077977882 0.880797077977882 0.880797077977882 0.952574126822433 0.952574126822433'), "pred_logistic calculates predicted probability value for logistic regression";
44
27
45
28
my$y = pdl(0, 1, 0, 1, 0);
46
-
ok tapprox( $y->d0(), 6.73011667009256 ), 'd0';
47
-
ok tapprox( $y->dm( ones(5) * .5 ), 6.93147180559945 ), 'dm';
48
-
ok tapprox( sum($y->dvrs(ones(5) * .5) ** 2), 6.93147180559945 ), 'dvrs';
0 commit comments