## WeBWorK Problems by Kenneth Appel -
Number of replies: 13
I am trying to write problems requested by middle school teachers.
What follows can clearly be done by inelegant methods, but I wonder if there is a nice way.

Problem: Fully factor 210mn^3.

numbers and letters would be accepted. Is there anything close? ### Re: Answers which are lists

by Davide Cervone -
Sure, the List() object produces an answer checker for an unordered list of any other MathObjects. So, for example, you could set the Context variables to be m and n and use a List() object:
    Context()->variables->are(m=>'Real',n=>'Real');
ANS(List("2,3,5,7,m,n,n,n")->cmp);

Is that what you are looking for?

Davide ### Re: Answers which are lists

by tim Payer -

Greetings,

I am having difficulty using List() to as an answer field.

I have read the previous posts but the there is a subtle point I am not getting.

Because this problem set is rather long I have just pulled out the essentials

##  The variable are assigned to and array...

$ot = Compute("$LOTf - $bl");$ot = Compute("$UOTf +$bh");

$ot = Compute("$UOTf + $bh*2"); ## Then based on a conditional two possible list of answers are generated: ## The student is to list the number of outliers in a boxplot problem and there could be two or three possible outliers. if ($wo > 2) {

$outly = List("$ot, $ot"); # if wo = 3,4,5 } else {$outly = List("$ot,$ot, $ot"); # if wo = 1, 2 } ## Lastly I am using a weighted grader in the problem. WEIGHTED_ANS( ($outly)->cmp, 3 );

## The problem is that the answer variable $outly is read as the number 1. I have tried replacing List() with Compute() and all manner of quotes with and without. Any help you can provide is most appreciated! Thanks, Tim In reply to tim Payer ### Re: Answers which are lists by Alex Jordan - Just a guess, but in: WEIGHTED_ANS( ($outly)->cmp, 3 );

"($outly)" is a perl array with one element. If it is evaluated in scalar context, it gives 1. Did you try just: WEIGHTED_ANS($outly->cmp, 3 );

? ### Re: Answers which are lists

by Glenn Rice -
The parentheses around $outly in the WEIGHTED_ANS method are not the problem in this case. In that context they are an unnecessary grouping symbol, but Perl doesn't evaluate that to a length one list. There is something else going on in the problem code that you are not showing. The shown code should work fine. I have tested it in a minimal problem, and it works fine with or without the parentheses around$outly in the WEIGHTED_ANS call. ### Re: Answers which are lists

by tim Payer -

Thank you Glenn,

The Complete problem set that converts a List to the number one is posted below..

The condition that assigns the variable $outly is on line 225. And yes, if I strip out every line of code so that the problem is just reporting one this one variable, then the$outly variable works for a comma separated list.

But I am at a loss as to what is causing the default value to go to the number one.

I apologize in advance for the lengthy code block.

$outly = Compute("$ot, $ot,$ot");  ## will equal 1
$outly = List("$ot, $ot,$ot");  ## will equal 1

##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();

"PGstandard.pl",

"PGunion.pl",

"PGbasicmacros.pl",

"MathObjects.pl",

"PGML.pl",

"PGnumericalmacros.pl",

"PGstatisticsmacros.pl",

"niceTables.pl",

"parserPopUp.pl",

"PGcourse.pl",

"PGchoicemacros.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); ########################$LOTt = floor($LOT); ## rounding decimals for re-assigninment$UOTt = floor($UOT); ## rounding decimals for re-assigninment$UOTf = Real($UOTt); ##$LOTf = Real($LOTt); ##$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 =  Compute("$LOTf - 2*$bl");

$ot = Compute("$LOTf - $bl");$ot =  Compute("$UOTf +$bh");

$srt =$ot;

$srt =$ot;

$srt[$n-1] = $ot;$srt = $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 = Compute("$LOTf -$bl");

$ot = Compute("$UOTf + $bh");$ot = Compute("$UOTf +$bh*2");

$srt =$ot;

$srt[$n-2] = $ot;$srt[$n-1] =$ot;

$srt =$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 = Compute("$UOTf + $bh");$ot = Compute("$UOTf +$bh*2");

$srt[$n-2] = $ot;$srt[$n-1] =$ot;

$srt =$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 = Compute("$LOTf - $bl*2");$ot = Compute("$LOTf -$bl");

$srt =$ot;

$srt =$ot;

$srt =$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 = Compute("$LOTf -$bl");

$ot = Compute("$UOTf + $bh");$srt = $ot;$srt[$n-1] =$ot;

$srt =$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"); #$out1 = Compute("$ot"); #$out2 = Compute("$ot"); #$outly = Compute("@ot");

if ($wo == 2) {$outly = Compute("$ot,$ot");  # if wo = 3,4,5

} else {

$outly = Compute("$ot, $ot,$ot");  # if wo = 1, 2

}

#$outly = List("$ot, $ot,$ot");

#   $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, $ot,$ot);  # if wo = 1, 2

#$outly = List($ot, $ot); # 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 = Compute("$LOTf +$ld2");  ## $nx -1$action2a = "reassigned $BR 3rd value$BR srt = $srt"; } elsif ($wo == 3) {

$srt = Compute("$LOTf +$ld3"); ##$nx -2

$srt = Compute("$LOTf +$ld3*2"); ##$nx -1

$action2a = "reassigned$BR 2nd & 3rd  value $BR srt =$srt $BR srt =$srt";

} 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 = 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 =$srt $BR srt[n-3] =$srt[$n-3]"; } } elsif ($nx == 4) {

if ($wo == 1) {$srt = 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 =$srt $BR srt[n-3] =$srt[$n -3]$BR srt[n-4] = $srt[$n -4]";

} elsif ($wo == 2) {$srt = Compute("$LOTf +$ld3");  ##

$srt = Compute("$LOTf +$ld3*2"); ##$srt[$n-4] = Compute("$UOTf - $hd2");$action2a = "reassigned $BR 3rd and 4th value$BR and 4th hi value $BR srt =$srt $BR srt =$srt $BR srt[n-4] =$srt[$n-4]"; } elsif ($wo == 3) {

$srt = Compute("$LOTf +$ld4"); ##$srt = Compute("$LOTf +$ld4*2");  ##

$srt = Compute("$LOTf +$ld4*3"); ##$srt[$n-4] = Compute("$UOTf - $hd2");$action2a = "reassigned $BR 2nd-4th values$BR and 4th hi value $BR srt =$srt $BR srt =$srt $BR srt =$srt $BR srt[n-4] =$srt[$n-4]"; } elsif ($wo == 4) {

$srt = 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 = $srt$BR srt[n-2] = $srt[$n -2] $BR srt[n-3] =$srt[$n -3]$BR srt[n-4] = $srt[$n -4]";

} else {

$srt = Compute("$LOTf +$ld3"); ##$srt = 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 = $srt$BR srt = $srt$BR srt[n-3] = $srt[$n-3] $BR srt[n-4] =$srt[$n-4]"; } } elsif ($nx == 5) {

if ($wo == 1) {$srt = Compute("$LOTf +$ld3");  ##

$srt = 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 = Compute("$LOTf +$ld4"); ##$srt = Compute("$LOTf +$ld4*2");  ##

$srt = Compute("$LOTf +$ld4*3"); ##$srt[$n-4] = Compute("$UOTf - $hd3");$srt[$n-5] = Compute("$UOTf - $hd3*2"); } elsif ($wo == 3) {

$srt = Compute("$LOTf +$ld5"); ##$srt = Compute("$LOTf +$ld5*2");  ##

$srt = Compute("$LOTf +$ld5*3"); ##$srt = Compute("$LOTf +$ld5*4");  ##

$srt[$n-4] = Compute("$UOTf -$hd3");

$srt[$n-5] = Compute("$UOTf -$hd3*2");

} elsif ($wo == 4) {$srt = Compute("$LOTf +$ld3");  ##

$srt = 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 = Compute("$LOTf +$ld4");  ##

$srt = Compute("$LOTf +$ld4*2"); ##$srt = 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 = Compute("$LOTf +$ld4"); ##$srt = Compute("$LOTf +$ld4*2");  ##

$srt = 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 = Compute("$LOTf +$ld5"); ##$srt = Compute("$LOTf +$ld5*2");  ##

$srt = Compute("$LOTf +$ld5*3"); ##$srt = 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 = Compute("$LOTf +$ld6");  ##

$srt = Compute("$LOTf +$ld6*2"); ##$srt = Compute("$LOTf +$ld6*3");  ##

$srt = Compute("$LOTf +$ld6*4"); ##$srt = 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 = Compute("$LOTf +$ld4");  ##

$srt = Compute("$LOTf +$ld4*2"); ##$srt = 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 = Compute("$LOTf +$ld5"); ##$srt = Compute("$LOTf +$ld5*2");  ##

$srt = Compute("$LOTf +$ld5*3"); ##$srt = 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 = Compute("$LOTf +$ld5"); ##$srt = Compute("$LOTf +$ld5*2");  ##

$srt = Compute("$LOTf +$ld5*3"); ##$srt = 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 = Compute("$LOTf +$ld6");  ##

$srt = Compute("$LOTf +$ld6*2"); ##$srt = Compute("$LOTf +$ld6*3");  ##

$srt = Compute("$LOTf +$ld6*4"); ##$srt = 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 = Compute("$LOTf +$ld7");  ##

$srt = Compute("$LOTf +$ld7*2"); ##$srt = Compute("$LOTf +$ld7*3");  ##

$srt = Compute("$LOTf +$ld7*4"); ##$srt = Compute("$LOTf +$ld7*5");  ##

$srt = 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 = Compute("$LOTf +$ld5"); ##$srt = Compute("$LOTf +$ld5*2");  ##

$srt = Compute("$LOTf +$ld5*3"); ##$srt = 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 = Compute("$LOTf +$ld6"); ##$srt = Compute("$LOTf +$ld6*2");  ##

$srt = Compute("$LOTf +$ld6*3"); ##$srt = Compute("$LOTf +$ld6*4");  ##

$srt = 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 = Compute("$LOTf +$ld6");  ##

$srt = Compute("$LOTf +$ld6*2"); ##$srt = Compute("$LOTf +$ld6*3");  ##

$srt = Compute("$LOTf +$ld6*4"); ##$srt = 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 = Compute("$LOTf +$ld7");  ##

$srt = Compute("$LOTf +$ld7*2"); ##$srt = Compute("$LOTf +$ld7*3");  ##

$srt = Compute("$LOTf +$ld7*4"); ##$srt = Compute("$LOTf +$ld7*5");  ##

$srt = 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 = Compute("$LOTf +$ld8"); ##$srt = Compute("$LOTf +$ld8*2");  ##

$srt = Compute("$LOTf +$ld8*3"); ##$srt = Compute("$LOTf +$ld8*4");  ##

$srt = Compute("$LOTf +$ld8*5"); ##$srt = Compute("$LOTf +$ld8*6");  ##

$srt = 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 = Compute("$LOTf +$ld6"); ##$srt = Compute("$LOTf +$ld6*2");  ##

$srt = Compute("$LOTf +$ld6*3"); ##$srt = Compute("$LOTf +$ld6*4");  ##

$srt = 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 = Compute("$LOTf +$ld7");  ##

$srt = Compute("$LOTf +$ld7*2"); ##$srt = Compute("$LOTf +$ld7*3");  ##

$srt = Compute("$LOTf +$ld7*4"); ##$srt = Compute("$LOTf +$ld7*5");  ##

$srt = 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 = $wl;$wL = $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: A Comparison of Bay Area Commute Times in Minutes:", headerrow => 1], "Sample $BR ID# ", "Commute$BR Time in $BR Minutes"], [["Given the following commute times in minutes were sampled from$n bay area $BR commuters, 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}|', ); @]*** [@ DataTable( [ [["Low end ", headerrow => 1], "High end", "OutliersBR $dot", "Whisker$BR terminates", "Action $BR Taken"], [["$lL " ]," $hL", "$oL", "$wkL", "$action2a"],

],

caption => " ",

midrules => 1,

align => '|p{1in}|p{1in}|p{1in}|p{1in}|p{2in}|',

);

@]***

n = [$n] dif = [$dif]

Q2 = [$Q2] Q1 = [$Q1]

Q3 = [$Q3] [$arc[floor($n*3/4)-1]]th value = [$srt[floor($n*3/4)-1]] [$arc[floor($n*3/4)]]th value = [$srt[floor($n*3/4)]] [$arc[floor($n*3/4)+1]]th value = [$srt[floor($n*3/4)+1]] LOT = [$LOT]

UOT = [$UOT] [$n] Random draws with [\pm] [$nx] values on either end to re-assign. ml = [$ml]

ld2 = [$ld2] Lower threshold at the [$arc[$nx]]th data point which is [$nx+1] places from bottom = [$ltn]. The difference between the threshold and LOT is [$ltn] - [$LOT] -[$bl] = [$ml]. Upper threshold at the [$arc[$n -$nx-1]]th data point which is [$nx+1] places from top = [$htn].

The difference between UOT and threshold is [$UOT] - [$htn]-[$bh] = [$mh].

ot0 = [$ot] ot1 = [$ot]

ot2 = [$ot] outly = [$outly]

END_PGML

Context()->normalStrings;

##############################################################

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(); ### Re: Answers which are lists

by Glenn Rice -

Can you post that as an attachment.  It never works well with cut and paste from the web browser.  Html elements always seem to mess up things.  It is easier for me in any case. ### Re: Answers which are lists

by tim Payer -

Sure thing Glenn,

I hope a note-pad document will suffice.

Tim ### Re: Answers which are lists

by Alex Jordan -

(In the middle/toward the end) of this block of code, I see:

$outly = Compute("1"); which would certainly explain why$outly is 1 :) :) :) ### Re: Answers which are lists

by tim Payer -
That has to be it!

I see it NOW!

Ugh, That was a dummy variable that I neglected to delete after the list variable was assigned.

Thank you so much and sorry for the trouble on such an obvious glitch.

Best, Tim 