diff --git a/OpenProblemLibrary/NAU/setProbability/ExpValueProbModel1.pg b/OpenProblemLibrary/NAU/setProbability/ExpValueProbModel1.pg index 6127ab1215..e741c111b2 100644 --- a/OpenProblemLibrary/NAU/setProbability/ExpValueProbModel1.pg +++ b/OpenProblemLibrary/NAU/setProbability/ExpValueProbModel1.pg @@ -17,44 +17,60 @@ DOCUMENT(); # This should be the first executable line in the problem. loadMacros( "PGstandard.pl", - "PGchoicemacros.pl", - "PGgraphmacros.pl", + "MathObjects.pl", + "PGML.pl", + "niceTables.pl", "PGcourse.pl" ); -TEXT(beginproblem()); -$showPartialCorrectAnswers = 1; +Context("Numeric"); +@seq=(); +for (0..12){ + push @seq, $_/2; +} + +@out = random_subset(4,@seq); -@out=(); -push @out, random(0,6,.5) foreach 0..3; @outcome=num_sort(@out); $a=random(0.05,.40,.05); $b=random(0.05,.40,.05); -$ans1=1-$a-$b-0.15; +$ans1=Real(1-$a-$b-0.15); @prob=($a,$b,0.15,$ans1); -$ans=0; +$ans2=0; for($i=0; $i<4; $i++){ - $ans=$ans+$outcome[$i]*$prob[$i]; + $ans2=$ans2+$outcome[$i]*$prob[$i]; } +$ans2=Real($ans2); + +$tab = DataTable( + [ + ["Outcome", $outcome[0], $outcome[1], $outcome[2], $outcome[3]], + ["Probability", $prob[0], $prob[1], $prob[2], ans_rule(5)] + ], + horizontalrules => 1, + texalignment => 'l|c|c|c|' +); + +BEGIN_PGML + +Below is a partially complete probability model. Enter the probability for the final outcome. + +[@ $tab @]* + +Find the expected value of the probability model. [__]{$ans1}{30} +END_PGML -BEGIN_TEXT +ANS($ans2->cmp()); -Below is a partially complete probability model. Enter the probability for the final outcome. $BR -\{begintable(9)\} -\{row("Outcome", $outcome[0], $outcome[1], $outcome[2], $outcome[3])\} -\{row("Probability", $prob[0], $prob[1], $prob[2], ans_rule(5))\} -\{endtable()\} $BR $BR -Find the expected value of the probability model. $BR $BR -\{ans_rule(30)\} -$BR -END_TEXT +BEGIN_PGML_SOLUTION +The probabilities must add up to 1, so the probability that the outcome equals [$outcome[3]] is 1-([$prob[0]]+[$prob[1]]+[$prob[2]]) = [$ans1] . -ANS(num_cmp($ans1)); -ANS(num_cmp($ans)); +The expected value is ([$prob[0]])([$outcome[0]])+([$prob[1]])([$outcome[1]])+([$prob[2]])([$outcome[2]])+([$ans1])([$outcome[3]])=[$ans2] . +END_PGML_SOLUTION ENDDOCUMENT(); # This should be the last executable line in the problem.