<?php function pid($x) { var_dump($x); return $x; } function f($x) { return $x; } function ttest() { return f(pid('arg1'), pid('arg2')); } ttest();
function printTtest() { $before = array(25, 25, 27, 44, 30, 67, 53, 53, 52, 60, 28); printf("before:"); foreach ($before as $elm) { printf(" %d", $elm); } printf("\n"); $after = array(27, 29, 37, 56, 46, 82, 57, 80, 61, 59, 43); printf("after:"); foreach ($after as $elm) { printf(" %d", $elm); } printf("\n"); $dArr = sampDiff($before, $after); printf("differences:"); foreach ($dArr as $elm) { printf(" %d", $elm); } printf("\n"); $dMean = sampMean($dArr); $dVar = sampVar($dArr); printf("mean: %.5f, var: %.5f\n", sampMean($dArr), sampVar($dArr)); $p = ttest($before, $after, true, 2, true, 0.95, $lower, $upper); printf("ttest(before, after, welch=true, sides=2, paired=true)" . " --> %.5f (%.5f .. %.5f)\n", $p, $lower, $upper); $p = ttest($before, $after, false, 2, true, 0.95, $lower, $upper); printf("ttest(before, after, welch=false, sides=2, paired=true)" . " --> %.5f (%.5f .. %.5f)\n", $p, $lower, $upper); }