WeBWorK Problems

"absolute" Tolerance is not effective?

"absolute" Tolerance is not effective?

by tim Payer -
Number of replies: 1
Greetings,

I have a perplexing problem in that I have set a tolerance for a problem set but it does not seem to have an affect in determining a student's answer as incorrect:

Context()->flags->set(tolerance => 0.1, tolType => "absolute");

I have used an absolute tolerance of: 0.1 does this not mean plus or minus 0.1 of the correct answer?  Still students are entering 2.09 and being marked "correct" when the correct answer is 2.41

Changing the "absolute" tolerance seems to have no affect.

Could you please point out the error that i am not seeing?

Thanks,   Tim

# DESCRIPTION   
# Stat 109 Data summarization
# WeBWorK problem written by TimPayer <tsp1@humboldt.edu>
# ENDDESCRIPTION

## DBsubject(Statistics)
## DBchapter(Exploratory data analysis/descriptive statistics)
## DBsection(Summary statistics)
## Institution(Humboldt State University)
## Author(Tim Payer)
## KEYWORDS(summations, mean, sd)

DOCUMENT();
loadMacros(
"PGstandard.pl",
"PGbasicmacros.pl",
"MathObjects.pl",
"PGML.pl",
"niceTables.pl",
"parserFormulaUpToConstant.pl"
);

Context("Numeric");
Context()->flags->set(tolerance => 0.1, tolType => "absolute");
install_problem_grader(~~&std_problem_grader);
$showPartialCorrectAnswers = 1;

## The beginning of 3.3 Stat 109 problem:
## Generate 4 random values and sort. 
## Calculate the mean and sd and sd window.

##  Problem 3.3a ###


$parsum = 0;
@draw1 = ();
foreach my $i (0..3) {
   $draw1 [$i] = random(11.0, 20.5,0.1);
   $sum1 = Compute("$draw1[$i] + $parsum");
   $parsum = $sum1; 
}


## Find the mean :

$ans1 = Compute("($sum1)/4");
$ansd1 =sprintf("%0.2f",$ans1);
$difa1 = $draw1[0] -$ansd1;
$difa2 = $draw1[1] -$ansd1;
$difa3 = $draw1[2] -$ansd1;
$difa4 = $draw1[3] -$ansd1;

$dsqa1 = $difa1**2;
$dsqa2 = $difa2**2;
$dsqa3 = $difa3**2;
$dsqa4 = $difa4**2;
$ssqa = $dsqa1+$dsqa2+$dsqa3+$dsqa4;
$ssqad = $ssqa/3;
$rrsqad = ($ssqad)**(0.5);
$rsqad =sprintf("%0.2f",$rrsqad);
$lba = $ansd1 - $rsqad;
$uba = $ansd1 + $rsqad;

## Find the squared deviations and sum
$parsum = 0;
@drawsd1 = ();
foreach my $i (0..3) {
   $drawsd1 [$i] = Compute("($draw1[$i]-$ans1)**2");
   $sumd1 = Compute("$drawsd1[$i] + $parsum");
   $parsum = $sumd1; 
}

$ans2 = Compute("($parsum/3)**(0.5)");
$ans3 = Compute("$ans1-$ans2");
$ans4 = Compute("$ans1+$ans2");


##  Problem 3.3b ###

Context()->flags->set(tolerance => 0.5);
$parsum = 0;
@drawb = ();
foreach my $i (0..4) {
   $drawb[$i] = random(5,18,1);
   $sum2 = Compute("$drawb[$i] + $parsum");
   $parsum = $sum2; 
}


## Find the mean :

$ans5 = Compute("$sum2/5");
$ga = gcd($sum2,5);

$n1 = $sum2/$ga;
$d1 = 5/$ga;

if($ga ==1){
$n2=$sum2;
$d2 = 5;
$f2="\frac{$n2}{$d2}";
}
elsif ($d1==1) {
$f2 = $n1;
} else {
$f2="\frac{$n1}{$d1}";
}

#$ansd5 =sprintf("%0.1f",$ans5);

## Find the squared deviations and sum
$parsum = 0;
@drawsdb = ();
foreach my $i (0..4) {
   $drawsdb [$i] = Compute("($drawb[$i]-$ans5)**2");
   $sumd2 = Compute("$drawsdb[$i] + $parsum");
   $parsum = $sumd2; 
}

$ans6 = Compute("($parsum/4)**(0.5)");
$ans7 = Compute("$ans5-$ans6");
$ans8 = Compute("$ans5+$ans6");

$difb1 = $drawb[0] -$ans5;
$difb2 = $drawb[1] -$ans5;
$difb3 = $drawb[2] -$ans5;
$difb4 = $drawb[3] -$ans5;
$difb5 = $drawb[4] -$ans5;

$dsqb1 = $difb1**2;
$dsqb2 = $difb2**2;
$dsqb3 = $difb3**2;
$dsqb4 = $difb4**2;
$dsqb5 = $difb5**2;
$ssqb = $dsqb1+$dsqb2+$dsqb3+$dsqb4+$dsqb5;
$ssqbd = $ssqb/4;
$rrsqbd = ($ssqbd)**(0.5);
$rsqbd =sprintf("%0.2f",$rrsqbd);
$lbb = $ans5 - $rsqbd;
$ubb = $ans5 + $rsqbd;



##  Problem 3.3c ###

$parsum = 0;
@drawc = ();
foreach my $i (0..4) {
   $drawc [$i] = random(-13,5,1);
   $sum3 = Compute("$drawc[$i] + $parsum");
   $parsum = $sum3; 
}


## Find the mean :

$ans9 = Compute("$sum3/5");
$ansd9 =sprintf("%0.2f",$ans9);
## Find the squared deviations and sum
$parsum = 0;
@drawsd1 = ();
foreach my $i (0..4) {
   $drawsd1 [$i] = Compute("($drawc[$i]-$ans9)**2");
   $sumd3 = Compute("$drawsd1[$i] + $parsum");
   $parsum = $sumd3; 
}

$ans10 = Compute("($parsum/4)**(0.5)");
$ans11 = Compute("$ans9-$ans10");
$ans12 = Compute("$ans9+$ans10");


$difc1 = $drawc[0] -$ans9;
$difc2 = $drawc[1] -$ans9;
$difc3 = $drawc[2] -$ans9;
$difc4 = $drawc[3] -$ans9;
$difc5 = $drawc[4] -$ans9;

$dsqc1 = $difc1**2;
$dsqc2 = $difc2**2;
$dsqc3 = $difc3**2;
$dsqc4 = $difc4**2;
$dsqc5 = $difc5**2;

$ssqc = $dsqc1+$dsqc2+$dsqc3+$dsqc4+$dsqc5;
$ssqcd = $ssqc/4;
$rrsqcd = ($ssqcd)**(0.5);
$rsqcd =sprintf("%0.2f",$rrsqcd);
$lbc = $ans9 - $rsqcd;
$ubc = $ans9 + $rsqcd;

BEGIN_PGML
*Drawn from lecture notes Week 2, Day 2.*  
 

3.5)  Determine the mean, standard deviation, and the first sd window for each group of values given below. Use hand calculation or use basic calculator work without a stat program.  
"Correct" answers will permit a tolerance of [``\pm 0.1``]  


3.5a)   [``\quad [$draw1[0]], \, [$draw1[1]], \, [$draw1[2]], \, [$draw1[3]] ``]  
 
[``\bar x``]  = [__________]{"$ans1"}  
 
[``sd``]  = [__________]{"$ans2"}  
 
Lower bound of sd window  = [__________]{"$ans3"}  
 
Upper bound of sd window   = [__________]{"$ans4"}  
 
 
3.5b)   [``\quad [$drawb[0]], \, [$drawb[1]], \, [$drawb[2]], \, [$drawb[3]], \, [$drawb[4]] ``]  
 

[``\bar x``]  = [__________]{"$ans5"}  
 
[``sd``]  = [__________]{"$ans6"}  
 
Lower bound of sd window  = [__________]{"$ans7"}  
 
Upper bound of sd window   = [__________]{"$ans8"}  
 
 
3.5c)   [``\quad [$drawc[0]], \, [$drawc[1]], \, [$drawc[2]], \, [$drawc[3]], \, [$drawc[4]] ``]  


[``\bar x``]  = [__________]{"$ans9"}  
 
[``sd``]  = [__________]{"$ans10"}  
 
Lower bound of sd window  = [__________]{"$ans11"}  
 
Upper bound of sd window   = [__________]{"$ans12"}  
 

 

END_PGML

BEGIN_PGML_SOLUTION
*SOLUTION*

3.5)  Determine the mean, standard deviation, and the first sd window for each group of values given below. Use hand calculation or use basic calculator work without a stat program.  
 
"Correct" answers will permit a tolerance of [``\pm 0.1``]


3.5a) The mean is calculated by summing all the data points and dividing by the number of data points.  

  [``\quad [$draw1[0]], \, [$draw1[1]], \, [$draw1[2]], \, [$draw1[3]] ``]  
 

[`` \bar x = \frac{1}{4} \sum_{i = 1}^{4}x_i =  \frac{1}{4} ([$draw1[0]]+ [$draw1[1]]+[$draw1[2]]+ [$draw1[3]])``]

[`` \bar x =  \frac{[$sum1]}{4}``]

[`` \bar x =  [$ansd1]``]  
 
The sd is calculated with the following expansion:  
 
[``\begin{aligned}&\\
sd &= \sqrt{ \frac{1}{n-1} \sum_{i =1}^n (x_i-\bar x)^2}  && \text{The formula for a sample sd. }\\  
sd &= \sqrt{ \frac{1}{n-1} \left((x_1-\bar x)^2+(x_2-\bar x)^2+(x_3-\bar x)^2+(x_4-\bar x)^2 \right) }   && \text{Expanding. }  
\end{aligned}``]  
 
Substituting each value into the expanded form gives the following expression:  

[``sd = \sqrt{ \frac{1}{4-1} \left(([$draw1[0]]-[$ansd1])^2+([$draw1[1]]-[$ansd1])^2+([$draw1[2]]-[$ansd1])^2+([$draw1[3]]-[$ansd1])^2 \right)} ``]   
[``\begin{aligned}&\\  
sd &= \sqrt{ \frac{1}{3} \left(([$difa1])^2+([$difa2])^2+([$difa3])^2+([$difa4])^2 \right) }   && \text{Taking the difference. }\\  
sd &= \sqrt{ \frac{1}{3} ([$dsqa1]+[$dsqa2]+[$dsqa3]+[$dsqa4]) } && \text{Squaring each term. }\\  
sd &= \sqrt{ \frac{[$ssqa]}{3} }    && \text{Summing the quantity }\\  
sd &= \sqrt{ [$ssqad] }    && \text{Dividing }\\  
sd &= [$rsqad]     && \text{Taking the square root. }\\  
\end{aligned}``]  
 

 
Now we combine the mean and sd to form the first sd window.
 
[``\begin{aligned}&\\  
\bar x  \pm sd &= [$ansd1] \pm [$rsqad] && \text{The mean and sd. }\\  
\bar x  - sd&= [$ansd1] - [$rsqad] = [$lba] && \text{The lower bound. }\\  
\bar x  + sd &= [$ansd1] + [$rsqad] = [$uba] && \text{The upper bound. }  
\end{aligned}``]  
 
 

3.5b) The mean is calculated by summing all the data points and dividing by the number of data points.  
 
[``\quad [$drawb[0]], \, [$drawb[1]], \, [$drawb[2]], \, [$drawb[3]], \, [$drawb[4]] ``]  

[`` \bar x = \frac{1}{5} \sum_{i = 1}^{5}x_i =  \frac{1}{5} ([$drawb[0]]+ [$drawb[1]]+[$drawb[2]]+ [$drawb[3]] + [$drawb[4]])``]

[`` \bar x =  \frac{[$sum2]}{5}``]

[`` \bar x =  [$f2]``]  

The sd is calculated with the following expansion:  
 
[``\begin{aligned}&\\
sd &= \sqrt{ \frac{1}{n-1} \sum_{i =1}^n (x_i-\bar x)^2}  && \text{The formula for a sample sd. }\\  
sd &= \sqrt{ \frac{1}{n-1} \left((x_1-\bar x)^2+(x_2-\bar x)^2+(x_3-\bar x)^2+(x_4-\bar x)^2 +(x_5-\bar x)^2 \right) }   && \text{Expanding. }  
\end{aligned}``]  
 
Substituting each value into the expanded form gives the following expression:  

[``sd = \sqrt{ \frac{1}{5-1} \left(([$drawb[0]]-[$f2])^2+([$drawb[1]]-[$f2])^2+([$drawb[2]]-[$f2])^2+([$drawb[3]]-[$f2])^2 +([$drawb[4]]-[$f2])^2 \right)} ``]   
[``\begin{aligned}&\\  
sd &= \sqrt{ \frac{1}{4} \left(([$difb1])^2+([$difb2])^2+([$difb3])^2+([$difb4])^2 +([$difb5])^2 \right) }   && \text{Taking the difference. }\\  
sd &= \sqrt{ \frac{1}{4} ([$dsqb1]+[$dsqb2]+[$dsqb3]+[$dsqb4]+[$dsqb5]) } && \text{Squaring each term. }\\  
sd &= \sqrt{ \frac{[$ssqb]}{4} }    && \text{Summing the quantity }\\  
sd &= \sqrt{ [$ssqbd] }    && \text{Dividing }\\  
sd &= [$rsqbd]     && \text{Taking the square root. }\\  
\end{aligned}``]  
 
 
Now we combine the mean and sd to form the first sd window.
 
[``\begin{aligned}&\\  
\bar x  \pm sd &= [$ans5] \pm [$rsqbd] && \text{The mean and sd. }\\  
\bar x  - sd &= [$ans5] - [$rsqbd] = [$lbb] && \text{The lower bound. }\\  
\bar x  + sd &= [$ans5] + [$rsqbd] = [$ubb] && \text{The upper bound. }  
\end{aligned}``]  
 
 
3.5c) The mean is calculated by summing all the data points and dividing by the number of data points.  
 
[``[$drawc[0]], \, [$drawc[1]], \,[$drawc[2]], \, [$drawc[3]] , \, [$drawc[4]]``]
 
[`` \bar x = \frac{1}{5} \sum_{i = 1}^{5}x_i =  \frac{1}{4} ([$drawc[0]]+ [$drawc[1]]+[$drawc[2]]+ [$drawc[3]] + [$drawc[4]])``]

[`` \bar x =  \frac{[$sum3]}{5}``]

[`` \bar x =  [$ansd9]``]  
 

The sd is calculated with the following expansion:  
 
[``\begin{aligned}&\\
sd &= \sqrt{ \frac{1}{n-1} \sum_{i =1}^n (x_i-\bar x)^2}  && \text{The formula for a sample sd. }\\  
sd &= \sqrt{ \frac{1}{n-1} \left((x_1-\bar x)^2+(x_2-\bar x)^2+(x_3-\bar x)^2+(x_4-\bar x)^2 +(x_5-\bar x)^2 \right) }   && \text{Expanding. }  
\end{aligned}``]  
 
Substituting each value into the expanded form gives the following expression:  

[``sd = \sqrt{ \frac{1}{5-1} \left(([$drawc[0]]-([$ans9]))^2+([$drawc[1]]-([$ans9]))^2+([$drawc[2]]-([$ans9]))^2+([$drawc[3]]-([$ans9]))^2 +([$drawc[4]]-([$ans9]))^2 \right)} ``]   
[``\begin{aligned}&\\  
sd &= \sqrt{ \frac{1}{4} \left(([$difc1])^2+([$difc2])^2+([$difc3])^2+([$difc4])^2 +([$difc5])^2 \right) }   && \text{Taking the difference. }\\  
sd &= \sqrt{ \frac{1}{4} ([$dsqc1]+[$dsqc2]+[$dsqc3]+[$dsqc4]+[$dsqc5]) } && \text{Squaring each term. }\\  
sd &= \sqrt{ \frac{[$ssqc]}{4} }    && \text{Summing the quantity }\\  
sd &= \sqrt{ [$ssqcd] }    && \text{Dividing }\\  
sd &= [$rsqcd]     && \text{Taking the square root. }\\  
\end{aligned}``]  
 
 
Now we combine the mean and sd to form the first sd window.
 
[``\begin{aligned}&\\  
\bar x  \pm sd &= [$ans9] \pm [$rsqcd] && \text{The mean and sd. }\\  
\bar x  - sd &= [$ans9] - [$rsqcd] = [$lbc] && \text{The lower bound. }\\  
\bar x  + sd &= [$ans9] + [$rsqcd] = [$ubc] && \text{The upper bound. }  
\end{aligned}``]  
 

END_PGML_SOLUTION

ENDDOCUMENT();

In reply to tim Payer

Re: "absolute" Tolerance is not effective?

by tim Payer -
Nevermind,

I saw that there was a second tolerance setting, please forgive my faslse alarm

Tim