########################################################################
## DESCRIPTION
## A WeBWorK problem that asks students to answer probability questions on a 
## sampling distribution.
## WeBWorK problem written by JoAnne Taormina, <joanne(dot)taormina(at)ncc(dot)edu>
## ENDDESCRIPTION
##
## KEYWORDS('sampling distribution', 'standard error', 'probability')
##
## Author('JoAnne Taormina')
## Institution('Nassau Community College')
########################################################################
DOCUMENT();        # This should be the first executable line in the problem.

loadMacros(
"PG.pl",
"PGstandard.pl",
"MathObjects.pl",
"PGbasicmacros.pl",
"PGchoicemacros.pl",
"PGanswermacros.pl",
"PGgraphmacros.pl",
"PGnumericalmacros.pl",
"PGstatisticsmacros.pl",
"weightedGrader.pl",
);
install_weighted_grader();

TEXT(beginproblem());
$showPartialCorrectAnswers = 1;

$n = random(5,10,1);
$mean = random(12.02,12.06,0.01);
$low = random(11.95,11.99,.01);
$high = random(12.01,12.05,.01);

$dev = random(0.09,0.13,0.01);
$newdev = $dev/sqrt($n);

#round newdev to 4 decimal places
$newdev = int(10000*$newdev+.5*($newdev <=> 0))/10000;

$ans1 = normal_prob($mean, 'infty', mean=>12, deviation=>$newdev);
#round ans1 to 4 decimal places
$ans1 = int(10000*$ans1+.5*($ans1 <=> 0))/10000;

$ans2 = normal_prob($low, $high, mean=>12, deviation=>$newdev);
#round ans2 to 4 decimal places
$ans2 = int(10000*$ans2+.5*($ans2 <=> 0))/10000;

$n_2 = random(10,15,1);
$mean_2 = random(119,119.4,0.01);
$high_2 = random(120,120.05,.01);

$dev_2 = random(0.6,0.7,0.01);
$stnd_error = $dev_2/sqrt($n_2);
$stnd_error  = int(10000*$stnd_error +.5*($stnd_error <=> 0))/10000;

$ans3 = normal_prob('-infty', $mean_2, mean=>119.54, deviation=>$stnd_error );
#round ans3 to 4 decimal places
$ans3 = int(10000*$ans3+.5*($ans3 <=> 0))/10000;

$ans4 = normal_prob($high_2,'infty', mean=>119.54, deviation=>$stnd_error );
#round ans4 to 4 decimal places
$ans4 = int(10000*$ans4+.5*($ans4 <=> 0))/10000;

$newdev = Compute($newdev);
$ans1 = Compute($ans1);
$ans2 = Compute($ans2);

$stnd_error = Compute($stnd_error);
$ans3 = Compute($ans3);
$ans4 = Compute($ans4);

BEGIN_TEXT

1.  Cans of regular Coke are labeled as containing \(12 \mbox{ oz}\). $BR
Statistics students weighed a sample of \($n\) randomly chosen cans, and found the sample mean
weight to be \($mean \mbox{ oz}\). $BR

Assume that cans of Coke are filled so that the actual amounts are normally distributed with a mean of \(12.00 \mbox{ oz}\)
and a population standard deviation of \($dev \mbox{ oz}\). 

$BR $BR
(a) Find the standard error of the sampling distribution.  $BITALIC Round your answer to 4 decimal places. $EITALIC
$BR
$BCENTER \{ans_rule(10)\} $ECENTER
$BR $BR
(b) Using the answer from part (a), find the probability that a sample of \($n\) cans will have a sample mean amount of at least \($mean \mbox{ oz}\). $BITALIC Round your answer to 4 decimal places. $EITALIC $BR

$BCENTER \{ans_rule(10)\} $ECENTER

$BR $BR
(c) Using the answer from part (a), find the probability that a sample of \($n\) cans will have a sample mean weight between \($low \mbox{ oz}\) and \($high \mbox{ oz}\). $BITALIC Round your answer to 4 decimal places. $EITALIC $BR

$BCENTER \{ans_rule(10)\} $ECENTER

$BR $BR
2.  The mean weight of an American newborn baby is \(119.54 \mbox{ oz}\) (about 7 pounds 8 ounces) with a population
standard deviation of \($dev_2 \mbox{ oz}\). 
$BR
In a random sample of \($n_2\) newborn babies, the mean weight was calculated to be \($mean_2 \mbox{ oz}\). $BR $BR
(a) Find the standard error of the sampling distribution.  $BITALIC Round your answer to 4 decimal places. $EITALIC
$BR
$BCENTER \{ans_rule(10)\} $ECENTER
$BR $BR
(b) Using your answer to part (a), what is the probability that in a random 
sample of \( $n_2 \) newborn babies, the mean weight is at most \( $mean_2 \mbox{ oz}\)? $BITALIC Round your answer to 4 decimal places. $EITALIC
$BR
$BCENTER \{ans_rule(10)\} $ECENTER
$BR $BR
(c)  Using your answer to part (a), what is the probability that in a random 
sample of \( $n_2 \) newborn babies, the mean weight is more than \( $high_2 \mbox{ oz}\)? $BITALIC Round your answer to 4 decimal places. $EITALIC
$BR
$BCENTER \{ans_rule(10)\} $ECENTER

END_TEXT

WEIGHTED_ANS( $newdev->cmp(tolType=>'absolute',tolerance=>0), 10 );
WEIGHTED_ANS( $ans1->cmp(tolType=>'absolute',tolerance=>0), 20 );
WEIGHTED_ANS( $ans2->cmp(tolType=>'absolute',tolerance=>0), 20 );
WEIGHTED_ANS( $stnd_error->cmp(tolType=>'absolute',tolerance=>0), 10 );
WEIGHTED_ANS( $ans3->cmp(tolType=>'absolute',tolerance=>0), 20 );
WEIGHTED_ANS( $ans4->cmp(tolType=>'absolute',tolerance=>0), 20 );

ENDDOCUMENT();       # This should be the last executable line in the problem.