Welch's t-test: Difference between revisions

m
→‎Integration using Simpson's Rule: Welsh to Welch, '×' for multiplication
m (→‎Using Burkhardt's 'incomplete beta': oops, stray variable, add comment marker)
m (→‎Integration using Simpson's Rule: Welsh to Welch, '×' for multiplication)
Line 1,102:
=== Integration using Simpson's Rule ===
 
{{works with|Rakudo|20172019.0811}}
{{trans|C}}
Perhaps "inspired by C example" may be more accurate. Gamma subroutine from [[Gamma_function#Perl_6 |Gamma function task]].
Line 1,108:
<lang perl6>sub Γ(\z) {
constant g = 9;
z < .5 ?? π / sin(π *× z) / Γ(1 - z) !!
τ.sqrt *× (z + g - 1/2)**(z - 1/2) *×
exp(-(z + g - 1/2)) *×
[+] <
1.000000000000000174663
Line 1,123:
0.5384136432509564062961e-7
-0.4023533141268236372067e-8
> Z* 1, |map 1/(z + *), 0..*
}
 
Line 1,135:
return 1 unless $a-variance && $b-variance;
 
my \WelshWelchs-𝒕-statistic = ($a-mean - $b-mean)/($a-variance/@A + $b-variance/@B).sqrt;
 
my $DoF = ($a-variance / @A + $b-variance / @B)² /
Line 1,141:
 
my $sa = $DoF / 2 - 1;
my $x = $DoF / (WelshWelchs-𝒕-statistic² + $DoF);
my $N = 65355;
my $h = $x / $N;
my ( $sum1, $sum2 );
 
for ^$N »*×» $h -> $i {
$sum1 += (($i + $h / 2) ** $sa) / (1 - ($i + $h / 2)).sqrt;
$sum2 += $i ** $sa / (1 - $i).sqrt;
}
 
(($h / 6) *× ( $x ** $sa / (1 - $x).sqrt + 4 *× $sum1 + 2 *× $sum2)) /
( Γ($sa + 1) *× π.sqrt / Γ($sa + 1.5) );
}
 
2,392

edits