I am using a list_random for 9 possible LOS values in a statistics homework problem. For some reason when either of these 3 LOS values: ($a1 = 0.10, $a1 = 0.00005, and $a1 = 0.000005) are selected they create error statements for two popups:
1. ERROR caught by Translator while processing problem file:tmpEdit/Payer/Stat_109/HW_14B/WNS_bats2/WNS_bats2.pg.tsp1.tmp **************** ERRORS from evaluating PG file:
The correct choice must be one of the PopUp menu items at line 2 of (eval 8287) Died within Value::Error called at line 136 of [PG]/macros/parserPopUp.pl from within parser::PopUp::new called at line 2 of (eval 8287) from within main::PopUp called at line 165 of (eval 8041)
Yet I have traced through these and do not see any errors and the other 6 of 9 LOS values run through without a problem.
Any insight is greatly appreciated...
Thank you, Tim
##DESCRIPTION
## Hypothesis test on one proportion.
##ENDDESCRIPTION
##KEYWORDS('confidence interval', 'confidence interpretation')
## DBsubject('Statisitics')
## DBchapter('Hypothesis test')
## DBsection('Real Numbers')
## Date('11/7/2016')
## Author('Tim Payer')
# DESCRIPTION Hypothesis test on one proportion.
# Use correct notation.
# WeBWorK problem written by TimPayer <tsp1@humboldt.edu>
# ENDDESCRIPTION
## DBsubject(Probability)
## DBchapter(Random variables)
## DBsection(Expectation)
## Institution(Humboldt State University)
## Author(Tim Payer)
## KEYWORDS(probability, translate, notation)
DOCUMENT();
loadMacros(
"PGstandard.pl",
"PGunion.pl",
"PGnumericalmacros.pl",
"PGstatisticsmacros.pl",
"MathObjects.pl",
"parserPopUp.pl",
"PGML.pl",
"unionTables.pl",
"niceTables.pl",
"PGcourse.pl",
"PGchoicemacros.pl",
"answerHints.pl",
"weightedGrader.pl"
);
install_weighted_grader();
#Text(beginproblem()); #uncomment
install_problem_grader(~~&std_problem_grader);
$showPartialCorrectAnswers = 1;
Context("Numeric");
Context()->flags->set(
tolerance => 0.01,
tolType => "absolute",
);
### Prob 14B.2) ########
$po = 0.8;
$n = random(65, 110,1);
$dd = random(0.60, 0.80, 0.01) ;
$y1 = floor($n*$dd);
$y = Compute("$y1");
$phat1 =$y/$n;
$phat = sprintf("%0.4f",$phat1);
#$phat1 =Compute("$phat2");
$fat ="\frac{$y}{$n}";
$pnp = Compute("$po*$n*(1-$po)");
$aa = Compute("0.80");
### One-tailed Scenarios:####
$r = list_random(0, 1, 2, 3, 4, 5, 6, 7, 8); ## permits random selections of a specified range.
$a1 = list_random(0.10, 0.05, 0.025, 0.01, 0.005, 0.001, 0.0005, 0.00005, 0.000005);
## The following commented out $a1 values cause errors and I can not
## trace their cause.
#$a1 = 0.10;
#$a1 = 0.00005;
#$a1 = 0.000005;
%ap1=( 0.10=>"10%", 0.05=>"5%", 0.025=>"2.5%", 0.01=>"1%", 0.005=> "0.5%", 0.001=> "0.1%", 0.0005=>"0.05%", 0.00005=>"0.005%", 0.000005=>"0.0005%");
%z1=( 0.10=>"1.282", 0.05=>"1.645", 0.025=>"1.960", 0.01=>"2.326", 0.005=> "2.576", 0.001=> "3.090", 0.0005=>"3.291", 0.00005=>"3.891", 0.000005=>"4.491");
## The following lines link the random list with the associated values
## of the next lists: #####
$ap1 = $ap1{$a1};
$z1=$z1{$a1};
########################
$zsam =Compute("($phat1-$po)/sqrt($po*(1-$po)/$n)");
$zh =Compute("-1*$zsam");
#$z1 = "3.090";
if($zh > $z1){
$in = "<";
$rj = "reject";
$dc = "decrease";
} else {
$in = ">";
$rj = "do not reject";
$dc = "increase";
}
## 1-tailed p-value brackets #####
if($zh < 1.282){
$pb1 = "(p > 0.10)";
} elsif((1.282 < $zh) and ($zh < 1.645) ) {
$pb1 = "(0.05 < p < 0.10)";
} elsif((1.645 < $zh) and ($zh < 1.960 )) {
$pb1 = "(0.025 < p < 0.05)";
} elsif((1.960 < $zh) and ($zh < 2.326) ) {
$pb1 = "(0.01 < p < 0.025)";
} elsif((2.326 < $zh) and ($zh < 2.576 )) {
$pb1 = "(0.005 < p < 0.01)";
} elsif((2.576 < $zh) and ($zh < 3.090 )) {
$pb1 = "(0.001 < p < 0.005)";
} elsif((3.090 < $zh) and ($zh < 3.291 )) {
$pb1 = "(0.0005 < p < 0.001)";
} elsif((3.291 < $zh) and ($zh < 3.891 )) {
$pb1 = "(0.00005 < p < 0.0005)";
} elsif((3.891 < $zh) and ($zh < 4.491 )) {
$pb1 = "(0.000005 < p < 0.00005)";
} else {
$pb1 = "(p < 0.000005)";
}
#$alfa = list_random('10%', '5%', '1%', '0.5%', '0.01%', '0.005%', '0.001%');
$popup0 = PopUp(
["Choose:", 'has', 'does not have' ], 'has');
$popup1 = PopUp(
["?", '=', 'not =', ' < ', ' >', '< or =', '> or =' ], '> or =');
$popup13 = PopUp(
["Choose:", 'mu', 'eta', 'p', 'sigma', 'x-bar' ,'x-tilde', 'p-hat', 'sd' ], 'mu');
$popup2 = PopUp(
["Choose:", 'mean', 'median', 'proportion', 'variance', 'standard deviation','percentage'], 'proportion');
$popup3 = PopUp(
["Choose:", 'survive.', 'die.', 'survive will exceed 80%.', 'die will exceed 80%.', 'survive will be about 80%.', 'die will be about 80%.', 'survive will be less than 80%.', 'die will be less than 80%.', 'survive will exceed '.$phat.'.', 'die will exceed '.$phat.'.', 'survive will be about '.$phat.'.', 'die will be about '.$phat.'.', 'survive will be less than '.$phat.'.', 'die will be less than '.$phat.'.'], 'die.');
$popup4 = PopUp(
["Choose:", 'mu', 'eta', 'p', 'sigma', 'x-bar' ,'x-tilde', 'p-hat', 'sd' ], 'p');
$popup5 = PopUp(
["Choose:", '=', 'not =', '< ', '>', '< or =', '> or =' ], '=');
$popup6 = PopUp(
["Choose:", ' 0', ' '.$phat.'', '80%', ' 0.80'], ' 0.80');
$popup7 = PopUp(
["Choose:", 'mu', 'eta', 'p', 'sigma', 'x-bar' ,'x-tilde', 'p-hat', 'sd' ], 'p');
$popup8 = PopUp(
["Choose:", '=', 'not =', '<', '>', '< or =', '> or =' ], '<');
$popup9 = PopUp(
["Choose:", ' 0', ' '.$phat.'', '80%', ' 0.80'], ' 0.80');
$poplos = PopUp(
['alpha ?', '0.20', "0.10", '0.05', '0.025', '0.02', '0.01', '0.005', '0.002', '0.001','0.0005', '0.0001', '0.00005', '0.00001', '0.000005'], $a1);
$popup10 = PopUp(
["Choose:", 'upper tailed', 'lower tailed', 'two tailed'], 'lower tailed');
$popup11 = PopUp(
["?", '-', '+', '+ or -'], '-');
$popup12 = PopUp(
["Z-Critical?", "1.282", "1.645","1.960", "2.326", "2.576", "3.090", "3.291", "3.891", "4.491"], $z1);
$pop14 = PopUp(
["LOS ??", "20%","10%", "5%", "2.5%", "2%", "1%", "0.5%", "0.2%", "0.1%", "0.05%", "0.01%", "0.005%", "0.001%", "0.0005%" ], $ap1);
$pop15 = PopUp(
["reject ?", "reject", "do not reject"], $rj);
$pop16 = PopUp(
["?", ">", "<"], $in);
$pop17 = PopUp(
["?", ">", "<"], $in);
$pop18 = PopUp(
["?", "-", "+", "+ or -"], "-");
$pop19 = PopUp(
["Z-Critical?", "1.282", "1.645","1.960", "2.326", "2.576", "3.090", "3.291", "3.891", "4.491"], $z1);
$pop20 = PopUp(
["?", ">", "<"], $in);
$pop21 = PopUp(
["which bracketed p-value?",
"(p > 0.20)","(p > 0.10)","(0.10 < p < 0.20)", "(0.05 < p < 0.10)", "(0.025 < p < 0.05)", "(0.02 < p < 0.05)", "(0.01 < p < 0.025)","(0.01 < p < 0.02)", "(0.005 < p < 0.01)", "(0.002 < p < 0.01)", "(0.001 < p < 0.005)", "(0.001 < p < 0.002)", "(0.0005 < p < 0.001)", "(0.0001 < p < 0.001)", "(0.00005 < p < 0.0005)", "(0.00001 < p < 0.0001)", "(0.000005 < p < 0.00005)","(p < 0.00001)", "(p < 0.000005)"], $pb1 );
$pop22 = PopUp(
["?", ">", "<"], $in);
$pop23 = PopUp(
["alpha ?", "0.20", "0.10", "0.05", "0.025", "0.02", "0.01", "0.005", "0.002", "0.001","0.0005", "0.0001", "0.00005", "0.00001", "0.000005"], $a1);
$pop24 = PopUp(
["?", "decrease", "increase", "remain unchanged"], $dc);
#### Begin Problem...
BEGIN_PGML
*Drawn from Lecture Notes: Week 7 Day 3.*
*14B.2)* In Virginia the big eared bat's population has dropped to a near endangered level of 10,000 due to White Nose Syndrome (WNS). WNS is a fungus the grows on the bats nose and wing tips of the blighted bat and has a mortality rate of 80% for all bats who catch the fungus. In an effort to treat WNS, biologists dusted an anti-fungal powder on a random sample of [$n] bats with WNS and yet [$y] of these bats still died. Was the anti-fungal powder effective in reducing the mortality rate for the big eared bat? Test the hypothesis at the [$ap1] LOS.
fat = [`[$fat]`]
zh = [$zh]
z1 = [$z1]
a1 = [$a1]
*14B.2) Step 1* Preliminary check on sample size.
Is [``n \cdot p_o(1-p_o) \ge 10``] ?
Then [``n \cdot p_o(1-p_o) ``] = [______] [$popup1->menu]* [``\Large{\text{10}}``]
We conclude that this data set [$popup0->menu]* an ample sample for hypothesis testing on one proportion.
END_PGML
BEGIN_TEXT
$PAR
$PAR
\{
DataTable(
[
['$BBOLD Note! $EBOLD Because of the limitations in software most special characters can not be included in a "pop-up" answer format and yet they are needed for the hypothesis formation. The pop-up selections will be in the text-form for the special characters embedded within the pop-up answer. Use the table at the right as a guide if needed.',' ',[image( "Symbol_translation.png", width=>165, height=>290, tex_size=>700 ) ] ,image( "Z_Table.png", width=>235, height=>212, tex_size=>700 ),]
],
caption => 'English text equivalence with special symbols, and an abbreviated Z-table: ',
midrules=>0,
align => 'p{3in} p{0.1in} p{2in}p{3in}'
);
\}
$PAR
END_TEXT
BEGIN_PGML
*14B.2) Step 2* Make selections that will create the best declaration of variable for the biologist's hypothesis.
[$popup13->menu]* = The [$popup2->menu]* of bats with WNS treated with anti-fungal powder that [$popup3->menu("pdes")]*
*14B.2) Step 3* Make selections that will create the correct hypothesis and LOS statement for the biologist's hypothesis.
[``\Large{H_o:}``] [$popup4->menu]* [$popup5->menu]* [$popup6->menu("pnot")]*
[``\Large{H_a:}``] [$popup7->menu]* [$popup8->menu]* [$popup9->menu("pnota")]*
[``\Large{\alpha =}``] [$poplos->menu]*
*14B.2) Step 4* The decision line for this hypothesis test is: [$popup10->menu]*
*14B.2) Step 5* The Z-critical value for this hypothesis test is:
Z-critical = [$popup11->menu]* [$popup12->menu]*
*14B.2) Step 6* The statistical conclusion for this hypothesis test is:
At the [$pop14->menu]* LOS we [$pop15->menu]* the null hypothesis of [``\large{H_o }``], because:
END_PGML
BEGIN_TEXT
$BR
$PAR
\{
DataTable(
[
[' Z Notational $BR Support: $BR $BR Numeric $BR Validation: ',' \(\hspace{10pt}\) \(\large{Z_{sample}}\) \(\hspace{2pt}\) '.$pop16->menu.' \(\hspace{2pt}\) \(\large{Z_{critical}}\) $BR $BR '.$zsam->ans_rule(5).' '.$pop17->menu.''.$pop18->menu.''.$pop19->menu.'' ],
],
caption => ' ',
midrules=>0,
align => 'p{1.2in}p{7in}'
);
\}
$PAR
\{
DataTable(
[
['p-Notational $BR Support: $BR $BR Numeric $BR Validation: ',' \(\hspace{115pt}\) \(\Large{p} \hspace{2pt}\) '.$pop20->menu.'\(\hspace{2pt} \Large{\alpha}\) $BR $BR '.$pop21->menu.''.$pop22->menu.''.$pop23->menu.'' ],
],
caption => ' ',
midrules=>0,
align => 'p{1.2in}p{7in}'
);
\}
$PAR
$BR
END_TEXT
BEGIN_PGML
*14B.2) Step 7* Write an English sentence conclusion.
The evidence supports the case that the mortality rate of bats afflicted with
WNS will [$pop24->menu]* when treated with anti-fungal powder.
END_PGML
#Adapted weighted answers values:
## Problems 14B.2 ##
WEIGHTED_ANS( ($pnp)->cmp, 7 );
WEIGHTED_ANS( ($popup1)->cmp, 1 );
WEIGHTED_ANS( ($popup0)->cmp, 1 );
WEIGHTED_ANS( ($popup13)->cmp, 4 );
WEIGHTED_ANS( ($popup2)->cmp, 4 );
NAMED_WEIGHTED_ANS(pdes => $popup3->cmp->withPostFilter(
AnswerHints(
"survive." => "No. Just what kind of rate is being measured?",
"die." => "Yes!",
["survive will exceed 80%.","survive will be about 80%.", "survive will be less than 80%.", 'survive will exceed '.$phat.'.', 'survive will be about '.$phat.'.' , 'survive will be less than '.$phat.'.' ] => "Survival rates are not sought, and do not restrict your variable declaration to a quantity.",
["die will exceed 80%.", "die will be about 80%.","die will be less than 80%.", 'die will exceed '.$phat.'.', 'die will be about '.$phat.'.', 'die will be less than '.$phat.'.'] => "Do not restrict your variable declaration to a quantity.",
)), 7 );
WEIGHTED_ANS( ($popup4)->cmp, 4 );
WEIGHTED_ANS( ($popup5)->cmp, 1 );
## Note below that numeric values and variables need to be converted to
## strings (text) by the addition of a leading blank space between the quote
## and the numeric value. Variables can read and rendered within popups
## by inserting periods before and after entry, called concatenation.
## all shown in this example below:
NAMED_WEIGHTED_ANS(pnot => $popup6->cmp->withPostFilter(
AnswerHints(
' 0'=>"The proportion is not zero.",
' '.$phat.''=>"Sample data should not be used in the hypothesis statement.",
'80%'=>"Percents are not the same as proportions.",
' 0.80'=>"Yes.",
)), 4 );
WEIGHTED_ANS( ($popup7)->cmp, 3 );
WEIGHTED_ANS( ($popup8)->cmp, 3 );
NAMED_WEIGHTED_ANS(pnota => $popup9->cmp->withPostFilter(
AnswerHints(
' 0'=>"The proportion is not zero.",
' '.$phat.''=>"Sample data should not be used in the hypothesis statement.",
'80%'=>"Percents are not the same as proportions.",
' 0.80'=>"Yes.",
)), 4 );
WEIGHTED_ANS( ($poplos)->cmp, 1 );
WEIGHTED_ANS( ($popup10)->cmp, 4 );
WEIGHTED_ANS( ($popup11)->cmp, 2 );
WEIGHTED_ANS( ($popup12)->cmp, 4 );
WEIGHTED_ANS( ($pop14)->cmp, 1 );
WEIGHTED_ANS( ($pop15)->cmp, 4 );
WEIGHTED_ANS( ($pop16)->cmp, 1 );
WEIGHTED_ANS( ($zsam)->cmp, 16 );
WEIGHTED_ANS( ($pop17)->cmp, 2 );
WEIGHTED_ANS( ($pop18)->cmp, 3 );
WEIGHTED_ANS( ($pop19)->cmp, 4 );
WEIGHTED_ANS( ($pop20)->cmp, 2 );
WEIGHTED_ANS( ($pop21)->cmp, 7 );
WEIGHTED_ANS( ($pop22)->cmp, 1 );
WEIGHTED_ANS( ($pop23)->cmp, 3 );
WEIGHTED_ANS( ($pop24)->cmp, 3 );
BEGIN_PGML_SOLUTION
The correct answers are coming....in 2017, Hah!
END_PGML_SOLUTION
ENDDOCUMENT();