##DESCRIPTION ## Boxplot data Generation with variable sample sizes ## Should include both N/4 and N not divisable by 4 ## outlier thresholds, and whisker terminals too ##ENDDESCRIPTION ##KEYWORDS('Statistics','Descriptive','Boxplots') ## Coordinate with actual categories in the Library another time... ## DBsubject('Statistics') ## DBchapter('Descriptive') ## DBsection('Boxplots') ## Date('8/17/2020') ## Author('Tim Payer') ## Institution('HSU') ## TitleText1('Stat 109 workbook') ## EditionText1('3') ## AuthorText1('Tim Payer') ## Section1('Lecture week 2') ## Problem1('Day 2') ######################################################################## DOCUMENT(); loadMacros( "PGstandard.pl", "PGunion.pl", "PGbasicmacros.pl", "MathObjects.pl", "PGML.pl", "PGnumericalmacros.pl", "PGstatisticsmacros.pl", "niceTables.pl", "parserPopUp.pl", "PGcourse.pl", "PGchoicemacros.pl", "answerHints.pl", "weightedGrader.pl", "parserFormulaUpToConstant.pl" ); # Print problem number and point value (weight) for the problem TEXT(beginproblem()); Context("Numeric"); # Show which answers are correct and which ones are incorrect $showPartialCorrectAnswers = 1; ############################################################## # Setup ## The beginning of Quiz 2 Stat 109 problem: ## Data table set up Lines 50-60 ############################################## #$err1 = 0.5; ## threshold for reporting round off error. #$N = 100; ## 100 unique numbers to draw on from 0-99 Used for NchooseK ## The following version condition $V for the n-list gives an equal chance of ## even and odd and N/4 and !N/4, while spanning n = 12 to 35. $V = random(1,3,1); if ( $V == 1 ) { $n = list_random(12, 15, 16, 19, 20, 23, 24, 27, 28, 31, 32, 35); } elsif ($V == 2) { $n = list_random(12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34); } else { $n = list_random(12, 13, 16, 17, 20, 21, 24, 25, 28, 29, 32, 33); } ### The plan is to take out n = 12 as being too small and requiring ### a specific re-assigning solution... $n = 17; # testing... $n4 = Compute("$n/4"); $nf = floor($n4); $dif = Compute("$n4-$nf"); ## The remainder after n/4 ## Select n distinct values from numbers 1 to N. ## The problem with NchooseK is that the number zero is always drawn. Why? #@c = NchooseK ($N, $n); ## #@srt = num_sort(@c); ## Sort the random draw. #$srtL = join("$BR ",@srt); ## Set the random draw data in a column ############################################################### ## Repeated Draws possible on forloop to fill array: @c = (); ## empty commuting data array @nc = (); ## empty counting data array foreach my $i ( 0..$n - 1 ) { $c[$i] = random(100,200,1); ## but this method permits ties... $nc[$i] = $i + 1; } ### This for loop counts the upper and lower values of the data set ### that exist before Q1 and after Q3. These data points will be overwritten ### in the array c to provide outliers and near outliers and whisker ends! if ( $dif == 0 ) { $nx = Compute("$nf -1"); # margin of soon to be reassigned values } else { $nx = Compute("$nf"); # margin of soon to be reassigned values } ############################### @srt = num_sort(@c); ## Sort the random draw. #$ncL = join("$BR ",@nc); ##???? @arc = 1..$n; ## fills an array with values 1 to n. $arcL = join("$BR ",@arc); ## Set the sequenced data in a column ########################################################## ## Calculate for Values based on the random draw alone. ## Note that since Arrays start at zero the anticpated count ## of say n/2 and n/2 + 1 will be represented at n/2 and n/2 -1 ## and the count of floor(n/2) +1 will be reached by floor(n/2) alone ############################################### if ( $dif== 0 ) { $Q1 = Compute("($srt[$n/4] + $srt[$n/4 - 1])/2 "); $Q3 = Compute("($srt[$n*3/4] + $srt[$n*3/4 - 1])/2 "); $Q2 = Compute("($srt[$n/2] + $srt[$n/2 - 1])/2 "); } elsif ( $dif== 0.5 ){ ### N is not /4 but dif = 0.5 $Q2 = Compute("($srt[$n/2] + $srt[$n/2 - 1])/2 "); $Q1 = Compute("$srt[floor($n/4)] "); $Q3 = Compute("$srt[floor($n*3/4)] "); } else { ### N is not /4 so dif = 0.25, 0.75 $Q2 = Compute("$srt[floor($n/2)]"); $Q1 = Compute("$srt[floor($n/4)] "); $Q3 = Compute("$srt[floor($n*3/4)] "); } $LOT = Compute("$Q1 -1.5*($Q3 - $Q1)"); $UOT = Compute("$Q3 + 1.5*($Q3 - $Q1)"); ### Reassigning the marginal values to extend whiskers ### and outlier possiblisities. $bl = random(2,7,1); # The small margin between low whisker end and LOT. $bh = random(2,7,1); # The small margin between UOT and hi whisker end. $ltn = Compute("$srt[$nx]"); # threshold values that can be changed $htn = Compute("$srt[$n -$nx-1]"); # while letting Q1, Q3, LOT, UOT, stay fixed $ml = Compute("$srt[$nx] - $LOT-$bl"); # difference between lowest fixed pt and LOT $mh = Compute("$UOT-$srt[$n-$nx-1]-$bh"); # difference between UOT and highest fixed point ### ml and mh (margin low and margin hi) is what is added (on the higher fixed pt) ### or subtracted from the lower fixed point, to establish the whisker terminal. ### The remaining data points are to be distributed over this span. ### ## Practice for re-assigning values @l= (); @h = (); foreach my $i ( 0..$nx - 1 ) { $l[$i] = $srt[$i]; $h[$i] = $srt[$n-1 - $i]; } $lL = join("$BR ",@l); $hL = join("$BR ",@h); ######################## $LOTf = floor($LOT); ## rounding decimals for re-assigninment $UOTf = floor($UOT); ## rounding decimals for re-assigninment $wl = Compute("$LOTf + $bl"); ## bottom whisker end $wh = Compute("$UOTf - $bh"); ## top whisker end ## Scenarios for whisker extension and outlier creation: # 1.) oolo = 2 outliers below, one above # 2.) oloo = 1 outlier below, two above # 3.) loo = 0 outliers below, two above # 4.) ool = 2 outliers below, 0 above # 5.) olo = 1 outlier below, 1 above # $ha = number of highest values re-assigned as outliers/whisker terminals # $la = number of lowest values re-assigned as outliers/whisker terminals $wo = random(1,5,1); ## Version generator for whisker and outlier scenarios $wo = 1; # Testing $ot =(); ## outlier listings if ( $wo == 1 ) { ## whiskers & outliers Accounted for: 3 low, 2 hi $ot[0] = Compute("$LOTf - 2*$bl"); $ot[1] = Compute("$LOTf - $bl"); $ot[2] = Compute("$UOTf + $bh"); $srt[0] = $ot[0]; $srt[1] = $ot[1]; $srt[$n-1] = $ot[2]; $srt[2] = $wl; ## low end whisker $srt[$n-2] = $wh; ## hi end whisker $dot = "wo = $wo $BR 3 outliers: $BR 2 low, 1 hi"; $ha = Compute("2"); $la = Compute("3"); } elsif ($wo == 2 ){ ## whiskers & outliers Accounted for: 2 low, 3 hi $ot[0] = Compute("$LOTf - $bl"); $ot[1] = Compute("$UOTf + $bh"); $ot[2] = Compute("$UOTf + $bh*2"); $srt[0] = $ot[0]; $srt[$n-2] = $ot[1]; $srt[$n-1] = $ot[2]; $srt[1] = $wl; ## low end whisker $srt[$n-3] = $wh; ## hi end whisker $dot = "wo = $wo $BR 3 outliers: $BR 1 low, 2 hi"; $ha = Compute("3"); $la = Compute("2"); } elsif ($wo == 3 ){ ## whiskers & outliers Accounted for: 1 low, 3 hi $ot[0] = Compute("$UOTf + $bh"); $ot[1] = Compute("$UOTf + $bh*2"); $srt[$n-2] = $ot[0]; $srt[$n-1] = $ot[1]; $srt[0] = $wl; ## low end whisker $srt[$n-3] = $wh; ## hi end whisker $dot = "wo = $wo $BR 2 outliers: $BR 0 low, 2 hi"; $ha = Compute("3"); $la = Compute("1"); } elsif ($wo == 4 ){ ## whiskers & outliers Accounted for: 3 low, 1 hi $ot[0] = Compute("$LOTf - $bl*2"); $ot[1] = Compute("$LOTf - $bl"); $srt[0] = $ot[0]; $srt[1] = $ot[1]; $srt[2] = $wl; ## low end whisker $srt[$n-1] = $wh; ## hi end whisker $dot = "wo = $wo $BR 2 outliers: $BR 2 low, 0 hi"; $ha = Compute("1"); $la = Compute("3"); } else { ## whiskers & outliers Accounted for: 2 low, 2 hi $ot[0] = Compute("$LOTf - $bl"); $ot[1] = Compute("$UOTf + $bh"); $srt[0] = $ot[0]; $srt[$n-1] = $ot[1]; $srt[1] = $wl; ## low end whisker $srt[$n-2] = $wh; ## hi end whisker $dot = "wo = $wo $BR 2 outliers: $BR 1 low, 1 hi"; $ha = Compute("2"); $la = Compute("2"); } #$out0 = Compute("$ot[0]"); #$out1 = Compute("$ot[1]"); #$out2 = Compute("$ot[2]"); # $outly = List("$ot[0], $ot[1], $ot[2]"); if ($wo > 2) { $outly = Compute("$ot[0], $ot[1]"); # if wo = 3,4,5 } else { $outly = Compute("$ot[0], $ot[1], $ot[2]"); # if wo = 1, 2 } $outly = List("$ot[0], $ot[1], $ot[2]"); # $outly = List("$out0, $out1, $out2"); #if ($wo > 2) { # $outly = List("$out0, $out1"); # if wo = 3,4,5 #} else { # $outly = List("$out0, $out1, $out2"); # if wo = 1, 2 #} #$outly = List($ot[0], $ot[1], $ot[2]); # if wo = 1, 2 #$outly = List($ot[0], $ot[1]); # if wo = 3,4,5 #$outly = List($otL); # as a comma separated array $oL = join("$BR ",@ot); $srtL = join("$BR ",@srt); ############################ ### Note that when $n = 12 or $nx = 2, and la = or ha = 3, that these whisker ### terminals will have to take on the values of srt(2) and srt(n-4) ## I will likely take out n = 12, as being more trouble than worth. ## Note that lines 145-218 account for the re-assignment of 4-5 values: ## The lowest 2 or 3 and the highest 2 or 3: ### All of which are Whisker terminals and outliers ################################### ### The last conditional deals with re-assignment of values that fall ### between Whiskers and Quartiles. The spacing of these value needs ### spreading and number of values will depend upon wo and nx scenarios: ################################## $ld2 = floor($ml/2); $hd2 = floor($mh/2); $ld3 = floor($ml/3); $hd3 = floor($mh/3); $ld4 = floor($ml/4); $hd4 = floor($mh/4); $ld5 = floor($ml/5); $hd5 = floor($mh/5); $ld6 = floor($ml/6); $hd6 = floor($mh/6); $ld7 = floor($ml/7); $hd7 = floor($mh/7); $ld8 = floor($ml/8); $hd8 = floor($mh/8); if ( $nx == 3 ) { if ($wo == 1) { $srt[$n-3] = Compute("$UOTf -$hd2"); ## $n - $nx $action2a = "reassigned $BR 3rd highest value $BR srt[n-3] = $srt[$n-3]"; } elsif ($wo == 2) { $srt[2] = Compute("$LOTf +$ld2"); ## $nx -1 $action2a = "reassigned $BR 3rd value $BR srt[2] = $srt[2]"; } elsif ($wo == 3) { $srt[1] = Compute("$LOTf +$ld3"); ## $nx -2 $srt[2] = Compute("$LOTf +$ld3*2"); ## $nx -1 $action2a = "reassigned $BR 2nd & 3rd value $BR srt[1] = $srt[1] $BR srt[2] = $srt[2]"; } elsif ($wo == 4) { $srt[$n-2] = Compute("$UOTf -$hd3"); ## $n -$nx +1 $srt[$n-3] = Compute("$UOTf -$hd3*2"); ## $nx -1 $action2a = "reassigned $BR 2nd & 3rd highest value $BR srt[n-2] = $srt[$n-2] $BR srt[n-3] = $srt[$n-3]"; } else { $srt[2] = Compute("$LOTf +$ld2"); ## $n -$nx +1 $srt[$n-3] = Compute("$UOTf - $hd2"); ## $nx -1 $action2a = "reassigned $BR 3rd lowest and 3rd highest value $BR srt[2] = $srt[2] $BR srt[n-3] = $srt[$n-3]"; } } elsif ($nx == 4) { if ($wo == 1) { $srt[3] = Compute("$LOTf +$ld2"); ## $srt[$n-3] = Compute("$UOTf -$hd3"); ## $srt[$n-4] = Compute("$UOTf -$hd3*2"); ## $action2a = "reassigned $BR 4th low value and 3rd and 4th from top $BR srt[3] = $srt[3] $BR srt[n-3] = $srt[$n -3] $BR srt[n-4] = $srt[$n -4]"; } elsif ($wo == 2) { $srt[2] = Compute("$LOTf +$ld3"); ## $srt[3] = Compute("$LOTf +$ld3*2"); ## $srt[$n-4] = Compute("$UOTf - $hd2"); $action2a = "reassigned $BR 3rd and 4th value $BR and 4th hi value $BR srt[2] = $srt[2] $BR srt[3] = $srt[3] $BR srt[n-4] = $srt[$n-4]"; } elsif ($wo == 3) { $srt[1] = Compute("$LOTf +$ld4"); ## $srt[2] = Compute("$LOTf +$ld4*2"); ## $srt[3] = Compute("$LOTf +$ld4*3"); ## $srt[$n-4] = Compute("$UOTf - $hd2"); $action2a = "reassigned $BR 2nd-4th values $BR and 4th hi value $BR srt[1] = $srt[1] $BR srt[2] = $srt[2] $BR srt[3] = $srt[3] $BR srt[n-4] = $srt[$n-4]"; } elsif ($wo == 4) { $srt[3] = Compute("$LOTf +$ld2"); ## $srt[$n-2] = Compute("$UOTf -$hd4"); ## $srt[$n-3] = Compute("$UOTf -$hd4*2"); ## $srt[$n-4] = Compute("$UOTf -$hd4*3"); ## $action2a = "reassigned $BR 4th low value and 2nd-4th from top $BR srt[3] = $srt[3] $BR srt[n-2] = $srt[$n -2] $BR srt[n-3] = $srt[$n -3] $BR srt[n-4] = $srt[$n -4]"; } else { $srt[2] = Compute("$LOTf +$ld3"); ## $srt[3] = Compute("$LOTf +$ld3*2"); ## $srt[$n-3] = Compute("$UOTf - $hd3"); $srt[$n-4] = Compute("$UOTf - $hd3*2"); $action2a = "reassigned $BR 3rd and 4th value $BR and 3rd- 4th hi value $BR srt[2] = $srt[2] $BR srt[3] = $srt[3] $BR srt[n-3] = $srt[$n-3] $BR srt[n-4] = $srt[$n-4]"; } } elsif ($nx == 5) { if ($wo == 1) { $srt[3] = Compute("$LOTf +$ld3"); ## $srt[4] = Compute("$LOTf +$ld3*2"); ## $srt[$n-3] = Compute("$UOTf -$hd4"); ## $srt[$n-4] = Compute("$UOTf -$hd4*2"); ## $srt[$n-5] = Compute("$UOTf -$hd4*3"); ## } elsif ($wo == 2) { $srt[2] = Compute("$LOTf +$ld4"); ## $srt[3] = Compute("$LOTf +$ld4*2"); ## $srt[4] = Compute("$LOTf +$ld4*3"); ## $srt[$n-4] = Compute("$UOTf - $hd3"); $srt[$n-5] = Compute("$UOTf - $hd3*2"); } elsif ($wo == 3) { $srt[1] = Compute("$LOTf +$ld5"); ## $srt[2] = Compute("$LOTf +$ld5*2"); ## $srt[3] = Compute("$LOTf +$ld5*3"); ## $srt[4] = Compute("$LOTf +$ld5*4"); ## $srt[$n-4] = Compute("$UOTf - $hd3"); $srt[$n-5] = Compute("$UOTf - $hd3*2"); } elsif ($wo == 4) { $srt[3] = Compute("$LOTf +$ld3"); ## $srt[4] = Compute("$LOTf +$ld3*2"); ## $srt[$n-2] = Compute("$UOTf -$hd5"); ## $srt[$n-3] = Compute("$UOTf -$hd5*2"); ## $srt[$n-4] = Compute("$UOTf -$hd5*3"); ## $srt[$n-5] = Compute("$UOTf -$hd5*4"); ## } else { $srt[2] = Compute("$LOTf +$ld4"); ## $srt[3] = Compute("$LOTf +$ld4*2"); ## $srt[4] = Compute("$LOTf +$ld4*3"); ## $srt[$n-3] = Compute("$UOTf - $hd4"); $srt[$n-4] = Compute("$UOTf - $hd4*2"); $srt[$n-5] = Compute("$UOTf - $hd4*3"); } } elsif ($nx == 6) { if ($wo == 1) { $srt[3] = Compute("$LOTf +$ld4"); ## $srt[4] = Compute("$LOTf +$ld4*2"); ## $srt[5] = Compute("$LOTf +$ld4*3"); ## $srt[$n-3] = Compute("$UOTf -$hd5"); ## $srt[$n-4] = Compute("$UOTf -$hd5*2"); ## $srt[$n-5] = Compute("$UOTf -$hd5*3"); ## $srt[$n-6] = Compute("$UOTf -$hd5*4"); ## } elsif ($wo == 2) { $srt[2] = Compute("$LOTf +$ld5"); ## $srt[3] = Compute("$LOTf +$ld5*2"); ## $srt[4] = Compute("$LOTf +$ld5*3"); ## $srt[5] = Compute("$LOTf +$ld5*4"); ## $srt[$n-4] = Compute("$UOTf - $hd4"); $srt[$n-5] = Compute("$UOTf - $hd4*2"); $srt[$n-6] = Compute("$UOTf - $hd4*3"); } elsif ($wo == 3) { $srt[1] = Compute("$LOTf +$ld6"); ## $srt[2] = Compute("$LOTf +$ld6*2"); ## $srt[3] = Compute("$LOTf +$ld6*3"); ## $srt[4] = Compute("$LOTf +$ld6*4"); ## $srt[5] = Compute("$LOTf +$ld6*5"); ## $srt[$n-4] = Compute("$UOTf - $hd4"); $srt[$n-5] = Compute("$UOTf - $hd4*2"); $srt[$n-6] = Compute("$UOTf - $hd4*3"); } elsif ($wo == 4) { $srt[3] = Compute("$LOTf +$ld4"); ## $srt[4] = Compute("$LOTf +$ld4*2"); ## $srt[5] = Compute("$LOTf +$ld4*3"); ## $srt[$n-2] = Compute("$UOTf -$hd6"); ## $srt[$n-3] = Compute("$UOTf -$hd6*2"); ## $srt[$n-4] = Compute("$UOTf -$hd6*3"); ## $srt[$n-5] = Compute("$UOTf -$hd6*4"); ## $srt[$n-6] = Compute("$UOTf -$hd6*5"); ## } else { $srt[2] = Compute("$LOTf +$ld5"); ## $srt[3] = Compute("$LOTf +$ld5*2"); ## $srt[4] = Compute("$LOTf +$ld5*3"); ## $srt[5] = Compute("$LOTf +$ld5*4"); ## $srt[$n-3] = Compute("$UOTf - $hd5"); $srt[$n-4] = Compute("$UOTf - $hd5*2"); $srt[$n-5] = Compute("$UOTf - $hd5*3"); $srt[$n-6] = Compute("$UOTf - $hd5*4"); } } elsif ($nx == 7) { if ($wo == 1) { $srt[3] = Compute("$LOTf +$ld5"); ## $srt[4] = Compute("$LOTf +$ld5*2"); ## $srt[5] = Compute("$LOTf +$ld5*3"); ## $srt[6] = Compute("$LOTf +$ld5*4"); ## $srt[$n-3] = Compute("$UOTf -$hd6"); ## $srt[$n-4] = Compute("$UOTf -$hd6*2"); ## $srt[$n-5] = Compute("$UOTf -$hd6*3"); ## $srt[$n-6] = Compute("$UOTf -$hd6*4"); ## $srt[$n-7] = Compute("$UOTf -$hd6*5"); ## } elsif ($wo == 2) { $srt[2] = Compute("$LOTf +$ld6"); ## $srt[3] = Compute("$LOTf +$ld6*2"); ## $srt[4] = Compute("$LOTf +$ld6*3"); ## $srt[5] = Compute("$LOTf +$ld6*4"); ## $srt[6] = Compute("$LOTf +$ld6*5"); ## $srt[$n-4] = Compute("$UOTf - $hd5"); $srt[$n-5] = Compute("$UOTf - $hd5*2"); $srt[$n-6] = Compute("$UOTf - $hd5*3"); $srt[$n-7] = Compute("$UOTf - $hd5*4"); } elsif ($wo == 3) { $srt[1] = Compute("$LOTf +$ld7"); ## $srt[2] = Compute("$LOTf +$ld7*2"); ## $srt[3] = Compute("$LOTf +$ld7*3"); ## $srt[4] = Compute("$LOTf +$ld7*4"); ## $srt[5] = Compute("$LOTf +$ld7*5"); ## $srt[6] = Compute("$LOTf +$ld7*6"); ## $srt[$n-4] = Compute("$UOTf - $hd5"); $srt[$n-5] = Compute("$UOTf - $hd5*2"); $srt[$n-6] = Compute("$UOTf - $hd5*3"); $srt[$n-7] = Compute("$UOTf - $hd5*4"); } elsif ($wo == 4) { $srt[3] = Compute("$LOTf +$ld5"); ## $srt[4] = Compute("$LOTf +$ld5*2"); ## $srt[5] = Compute("$LOTf +$ld5*3"); ## $srt[6] = Compute("$LOTf +$ld5*4"); ## $srt[$n-2] = Compute("$UOTf -$hd7"); ## $srt[$n-3] = Compute("$UOTf -$hd7*2"); ## $srt[$n-4] = Compute("$UOTf -$hd7*3"); ## $srt[$n-5] = Compute("$UOTf -$hd7*4"); ## $srt[$n-6] = Compute("$UOTf -$hd7*5"); ## $srt[$n-7] = Compute("$UOTf -$hd7*6"); ## } else { $srt[2] = Compute("$LOTf +$ld6"); ## $srt[3] = Compute("$LOTf +$ld6*2"); ## $srt[4] = Compute("$LOTf +$ld6*3"); ## $srt[5] = Compute("$LOTf +$ld6*4"); ## $srt[6] = Compute("$LOTf +$ld6*5"); ## $srt[$n-3] = Compute("$UOTf - $hd6"); $srt[$n-4] = Compute("$UOTf - $hd6*2"); $srt[$n-5] = Compute("$UOTf - $hd6*3"); $srt[$n-6] = Compute("$UOTf - $hd6*4"); $srt[$n-7] = Compute("$UOTf - $hd6*5"); } } else { ### when $nx = 8 if ($wo == 1) { $srt[3] = Compute("$LOTf +$ld6"); ## $srt[4] = Compute("$LOTf +$ld6*2"); ## $srt[5] = Compute("$LOTf +$ld6*3"); ## $srt[6] = Compute("$LOTf +$ld6*4"); ## $srt[7] = Compute("$LOTf +$ld6*5"); ## $srt[$n-3] = Compute("$UOTf -$hd7"); ## $srt[$n-4] = Compute("$UOTf -$hd7*2"); ## $srt[$n-5] = Compute("$UOTf -$hd7*3"); ## $srt[$n-6] = Compute("$UOTf -$hd7*4"); ## $srt[$n-7] = Compute("$UOTf -$hd7*5"); ## $srt[$n-8] = Compute("$UOTf -$hd7*6"); ## } elsif ($wo == 2) { $srt[2] = Compute("$LOTf +$ld7"); ## $srt[3] = Compute("$LOTf +$ld7*2"); ## $srt[4] = Compute("$LOTf +$ld7*3"); ## $srt[5] = Compute("$LOTf +$ld7*4"); ## $srt[6] = Compute("$LOTf +$ld7*5"); ## $srt[7] = Compute("$LOTf +$ld7*6"); ## $srt[$n-4] = Compute("$UOTf - $hd6"); $srt[$n-5] = Compute("$UOTf - $hd6*2"); $srt[$n-6] = Compute("$UOTf - $hd6*3"); $srt[$n-7] = Compute("$UOTf - $hd6*4"); $srt[$n-8] = Compute("$UOTf - $hd6*5"); } elsif ($wo == 3) { $srt[1] = Compute("$LOTf +$ld8"); ## $srt[2] = Compute("$LOTf +$ld8*2"); ## $srt[3] = Compute("$LOTf +$ld8*3"); ## $srt[4] = Compute("$LOTf +$ld8*4"); ## $srt[5] = Compute("$LOTf +$ld8*5"); ## $srt[6] = Compute("$LOTf +$ld8*6"); ## $srt[7] = Compute("$LOTf +$ld8*7"); ## $srt[$n-4] = Compute("$UOTf - $hd6"); $srt[$n-5] = Compute("$UOTf - $hd6*2"); $srt[$n-6] = Compute("$UOTf - $hd6*3"); $srt[$n-7] = Compute("$UOTf - $hd6*4"); $srt[$n-8] = Compute("$UOTf - $hd6*5"); } elsif ($wo == 4) { $srt[3] = Compute("$LOTf +$ld6"); ## $srt[4] = Compute("$LOTf +$ld6*2"); ## $srt[5] = Compute("$LOTf +$ld6*3"); ## $srt[6] = Compute("$LOTf +$ld6*4"); ## $srt[7] = Compute("$LOTf +$ld6*5"); ## $srt[$n-2] = Compute("$UOTf -$hd8"); ## $srt[$n-3] = Compute("$UOTf -$hd8*2"); ## $srt[$n-4] = Compute("$UOTf -$hd8*3"); ## $srt[$n-5] = Compute("$UOTf -$hd8*4"); ## $srt[$n-6] = Compute("$UOTf -$hd8*5"); ## $srt[$n-7] = Compute("$UOTf -$hd8*6"); ## $srt[$n-8] = Compute("$UOTf -$hd8*7"); ## } else { $srt[2] = Compute("$LOTf +$ld7"); ## $srt[3] = Compute("$LOTf +$ld7*2"); ## $srt[4] = Compute("$LOTf +$ld7*3"); ## $srt[5] = Compute("$LOTf +$ld7*4"); ## $srt[6] = Compute("$LOTf +$ld7*5"); ## $srt[7] = Compute("$LOTf +$ld7*6"); ## $srt[$n-3] = Compute("$UOTf - $hd7"); $srt[$n-4] = Compute("$UOTf - $hd7*2"); $srt[$n-5] = Compute("$UOTf - $hd7*3"); $srt[$n-6] = Compute("$UOTf - $hd7*4"); $srt[$n-7] = Compute("$UOTf - $hd7*5"); $srt[$n-8] = Compute("$UOTf - $hd7*6"); } } ##################### ## Print out outliers and re-assigned sorted values.. $oL = join("$BR ",@ot); $srtL = join("$BR ",@srt); ########################### #### Print out Whisker ends: @wL = (); $wL[0] = $wl; $wL[1] = $wh; $wkL = join("$BR ",@wL); ########################### $lowsk = Compute("$wl"); $hiwsk = Compute("$wh"); $outly = Compute("1"); $nm2 = $arc[$n-2]; $nm1 = $arc[$n-1]; $nm0 = $arc[$n]; $np1 = $arc[$n+1]; $np2 = $arc[$n+2]; #use Math::Random qw(random_poisson); # Could not get this to work #my $rnd = random_poisson($n, $mu); ############################################################## # Text Context()->texStrings; BEGIN_PGML [@ DataTable( [ [["Stat 109, Quiz 2: The Incidence of Flu at High Schools :", headerrow => 1], "School $BR ID# ", "Number of $BR Flu Cases "], [["Given the following counts of flu cases were sampled from $n high schools across the $BR state of California, find the following component value for a boxplot of the data set. $BR $BR \\(\\large{\\tilde x =}\\)".$Q2->ans_rule(5)." $BR $BR\\(Q_1 = \\) ".$Q1->ans_rule(5)."$BR $BR \\(Q_3 = \\) ".$Q3->ans_rule(5)."$BR $BR\\(LOT = \\) ".$LOT->ans_rule(5)." $BR $BR \\(UOT = \\) ".$UOT->ans_rule(5)." $BR $BR The data point at which the lower whisker terminates is: ".$lowsk->ans_rule(5)." $BR $BR The data point at which the upper whisker terminates is: ".$hiwsk->ans_rule(5)." $BR Report any outliers in a comma separated list here: ".$outly->ans_rule(10)." $BR"], "$arcL", "$srtL"], ], caption => " ", midrules => 1, align => '|p{6in}|p{0.6in}|p{0.8in}|', ); @]*** END_PGML Context()->normalStrings; ############################################################## # Answers: WEIGHTED_ANS( ($Q2)->cmp, 3 ); WEIGHTED_ANS( ($Q1)->cmp, 3 ); WEIGHTED_ANS( ($Q3)->cmp, 3 ); WEIGHTED_ANS( ($LOT)->cmp, 3 ); WEIGHTED_ANS( ($UOT)->cmp, 3 ); WEIGHTED_ANS( ($lowsk)->cmp, 3 ); WEIGHTED_ANS( ($hiwsk)->cmp, 3 ); WEIGHTED_ANS( ($outly)->cmp, 3 ); ENDDOCUMENT();