Difference between revisions of "Homework 0"

From Biolecture.org
imported>Tae Joo Hwang
imported>Tae Joo Hwang
 
Line 10: Line 10:
 
$sigma = sqrt( ((@set_a-1)*$var_a + (@set_b-1)*$var_b) / $df );<br />
 
$sigma = sqrt( ((@set_a-1)*$var_a + (@set_b-1)*$var_b) / $df );<br />
 
$p = ($avg_a - $avg_b) / ($sigma * sqrt( 1/@set_a + 1/@set_b));</p>
 
$p = ($avg_a - $avg_b) / ($sigma * sqrt( 1/@set_a + 1/@set_b));</p>
 +
 +
<p>print(p)</p>

Latest revision as of 17:19, 7 May 2018

foreach (@set_a) { $sum_a += $_ };
foreach (@set_b) { $sum_b += $_ };
$avg_a = $sum_a / @set_a;
$avg_b = $sum_b / @set_b;
foreach (@set_a) { $var_a += ( $_ - $avg_a )**2 }; 
$var_a /= (@set_a-1);
foreach (@set_b) { $var_b += ( $_ - $avg_b )**2 }; 
$var_b /= (@set_b-1);
$df = @set_a + @set_b -2;
$sigma = sqrt( ((@set_a-1)*$var_a + (@set_b-1)*$var_b) / $df );
$p = ($avg_a - $avg_b) / ($sigma * sqrt( 1/@set_a + 1/@set_b));

print(p)