Difference between revisions of "Homework 0"

From Biolecture.org
imported>Tae Joo Hwang
(Created page with "<pre> 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 };...")
 
imported>Tae Joo Hwang
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<pre>
+
<p>foreach (@set_a) { $sum_a += $_ };<br />
foreach (@set_a) { $sum_a += $_ };
+
foreach (@set_b) { $sum_b += $_ };<br />
foreach (@set_b) { $sum_b += $_ };
+
$avg_a = $sum_a / @set_a;<br />
$avg_a = $sum_a / @set_a;
+
$avg_b = $sum_b / @set_b;<br />
$avg_b = $sum_b / @set_b;
+
foreach (@set_a) { $var_a += ( $_ - $avg_a )**2 };&nbsp;<br />
foreach (@set_a) { $var_a += ( $_ - $avg_a )**2 };  
+
$var_a /= (@set_a-1);<br />
$var_a /= (@set_a-1);
+
foreach (@set_b) { $var_b += ( $_ - $avg_b )**2 };&nbsp;<br />
foreach (@set_b) { $var_b += ( $_ - $avg_b )**2 };  
+
$var_b /= (@set_b-1);<br />
$var_b /= (@set_b-1);
+
$df = @set_a + @set_b -2;<br />
$df = @set_a + @set_b -2;
+
$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 );
+
$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));</pre>
+
 
 +
<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)