######################################################################## ## DESCRIPTION ## A WeBWorK problem that asks students to conduct a hypothesis test ## involving two sample means. ## WeBWorK problem written by JoAnne Taormina, ## ENDDESCRIPTION ## ## KEYWORDS('hypothesis test, 'two sample t-test', 'p-value') ## ## Author('JoAnne Taormina') ## Institution('Nassau Community College') ######################################################################## DOCUMENT(); # This should be the first executable line in the problem. loadMacros( "PG.pl", "PGbasicmacros.pl", "PGchoicemacros.pl", "PGanswermacros.pl", "PGstatisticsmacros.pl", "PGnumericalmacros.pl", "weightedGrader.pl", "PGstandard.pl", "MathObjects.pl", "parserPopUp.pl", ); install_weighted_grader(); TEXT(beginproblem()); $showPartialCorrectAnswers = 1; $xbar1 = random(550,600,1); $n1 = random(12,18,1); $s1 = random(170,190,1); $xbar2 = random(700,750,1); $n2 = random(20,25,1); $s2 = random(250,270,1); $alpha = 5; $mean_samp_dist = 0; @choices = ("no difference", "a negative difference", "a positive difference"); @choices = @choices[shuffle(3)]; $popup_H0_direction = PopUp(["Choose:",$choices[0], $choices[1], $choices[2]], "no difference"); @choices = ("population mean", "sample mean", "population proportion", "sample proportion"); @choices = @choices[shuffle(4)]; $popup_H0_mean = PopUp(["Choose:",$choices[0], $choices[1], $choices[2], $choices[3]], "population mean"); @choices = ("population mean", "sample mean", "population proportion", "sample proportion"); @choices = @choices[shuffle(4)]; $popup_Ha_mean1 = PopUp(["Choose:",$choices[0], $choices[1], $choices[2], $choices[3]], "population mean"); $popup_Ha_mean2 = PopUp(["Choose:",$choices[0], $choices[1], $choices[2], $choices[3]], "population mean"); @choices = ("is the same as", "is greater than", "is less than"); @choices = @choices[shuffle(3)]; $popup_Ha_direction = PopUp(["Choose:",$choices[0], $choices[1], $choices[2]],"is less than"); # set up for a multiple choice problem. $radio_samp_dist_mean = new_multiple_choice(); $radio_samp_dist_mean->qa("The correct symbol for mean of the sampling distribution is ", "\( \mu_{\bar{x}_1-\bar{x}_2} \)"); $radio_samp_dist_mean->extra("\( \mu_{\bar{x}} \)", "\( \bar{x} \)", "\( \bar{x}_1-\bar{x}_2 \)", "\( \mu_{\hat{p}} \)", "\( \mu \)"); # set up for a multiple choice problem. $radio_dist = new_multiple_choice(); $radio_dist->qa("Choose the correct distribution", "T-Distribution"); $radio_dist->extra("Normal Distribution"); # set up for a multiple choice problem. $radio_dist_reason = new_multiple_choice(); $radio_dist_reason->qa("Why?", "We are not provided with \( \sigma \) for the two populations."); $radio_dist_reason->extra("We are provided with \( \sigma \) for the two populations.", "The size of n1 < 30 and n2 < 30", "We are provided with \( \bar{x}_1 \) and \( \bar{x}_2 \)."); @choices = ("less than or equal to 0.05", "greater than or equal to 0.05", "less than or equal to 0.0005", "greater than or equal to 0.0005","equal to 0.05", "equal to 0.0005"); @perm = shuffle(6); @choices = @choices[@perm]; $popup_p_value = PopUp(["Choose:",$choices[0], $choices[1], $choices[2], $choices[3], $choices[4], $choices[5]],"less than or equal to 0.05"); # set up for a multiple choice problem. $radio_samp_stat = new_multiple_choice(); $radio_samp_stat->qa("Symbol of the sample statistic:", "\( \bar{x}_1-\bar{x}_2 \)" ); $radio_samp_stat->extra("\( \bar{x}_2-\bar{x}_1 \)", "\( \mu_{\bar{x}} \)", "\( \bar{x} \)", "\( \mu_{\bar{x}_1-\bar{x}_2} \)"); $a = ($n1 - 1)*($s1**2) + ($n2 - 1)*($s2**2); $df = ($n1 + $n2 - 2); $c = (1/$n1 + 1/$n2); $standard_error = sqrt($a/$df*$c); $sample_stat = ($xbar1 - $xbar2); $t_score = $sample_stat/$standard_error; $p_value = 1 - tprob($df, $t_score ); $p_value = int(10000*$p_value+.5*($p_value <=> 0))/10000; $alpha = Compute($alpha); $mean_samp_dist = Compute($mean_samp_dist); $p_value = Compute($p_value); $sample_stat = Compute($sample_stat); @choices = ("Reject Ho and accept Ha", "Reject Ha and accept Ho", "Fail to reject Ho", "Fail to reject Ha"); @choices = @choices[shuffle(4)]; if($p_value <= .05) { $correct_h = "Reject Ho and accept Ha"; $correct_i = "Yes, because the mean bumper repair cost for small cars is significantly less than mean bumper repair cost for midsize cars."; $extra_i[0] = "No, because the mean bumper repair cost for small cars is not significantly less than mean bumper repair cost for midsize cars."; } else { $correct_h = "Fail to reject Ho"; $correct_i = "No, because the mean bumper repair cost for small cars is not significantly less than mean bumper repair cost for midsize cars."; $extra_i[0] = "Yes, because the mean bumper repair cost for small cars is significantly less than mean bumper repair cost for midsize cars."; } $popup_conclusion = PopUp(["Choose:",$choices[0], $choices[1], $choices[2], $choices[3]],$correct_h); # set up for a multiple choice problem. $radio_answer = new_multiple_choice(); $radio_answer->qa("Is the mean bumper repair cost less for small cars than it is for midsize cars?", $correct_i); $extra_i[1] = "Yes, because the mean bumper repair cost for small cars is not significantly less than mean bumper repair cost for midsize cars."; $extra_i[2] = "No, because the mean bumper repair cost for small cars is significantly less than mean bumper repair cost for midsize cars."; $radio_answer->extra($extra_i[0], $extra_i[1], $extra_i[2]); # set up for a multiple choice problem. $radio_type1_error = new_multiple_choice(); $radio_type1_error->qa("If a type I error were made in this test, it would mean", "there is no difference in the population mean bumper repair costs for smaller cars and midsized cars, but we incorrectly rejected the null hypothesis."); $radio_type1_error->extra("there is a significant difference in the population mean bumper repair costs for smaller cars and midsized cars, but we incorrectly rejected the null hypothesis.", "there is no difference in the population mean bumper repair costs for smaller cars and midsized cars, but we incorrectly failed to reject the null hypothesis.", "there is a significant difference in the population mean bumper repair costs for smaller cars and midsized cars, but we incorrectly failed to reject the null hypothesis."); # set up for a multiple choice problem. $radio_type2_error = new_multiple_choice(); $radio_type2_error->qa("If a type II error were made in this test, it would mean", "there is a significant difference in the population mean bumper repair costs for smaller cars and midsized cars, but we incorrectly failed to reject the null hypothesis."); $radio_type2_error->extra("there is no difference in the population mean bumper repair costs for smaller cars and midsized cars, but we incorrectly rejected the null hypothesis.", "there is a significant difference in the population mean bumper repair costs for smaller cars and midsized cars, but we incorrectly rejected the null hypothesis.", "there is no difference in the population mean bumper repair costs for smaller cars and midsized cars, but we incorrectly failed to the null hypothesis."); BEGIN_TEXT In crash tests at five miles per hour, the mean bumper repair cost for \( $n1\) small cars is \( $xbar1\) dollars with a standard deviation of \( $s1\) dollars. In similar test of \( $n2\) midsize cars, the mean bumper repair cost is \( $xbar2\) dollars with a standard deviation of \( $s2\) dollars. Conduct a hypothesis test based on this sample data, with \( \alpha = $alpha%\). Answer the question, is the mean bumper repair cost less for small cars than it is for midsize cars? $PAR $BBOLD (a) $EBOLD State the hypotheses: $BR $BR \(H_0:\) $SPACE There is \{ $popup_H0_direction->menu() \} $SPACE between the \{ $popup_H0_mean->menu() \} $SPACE bumper repair cost for small cars and midsize cars. $BR $BR \(H_a:\) $SPACE The \{ $popup_Ha_mean1->menu() \} $SPACE bumper repair cost for smaller cars \{ $popup_Ha_direction->menu() \} $SPACE the \{ $popup_Ha_mean2->menu() \} $SPACE bumper repair cost for midsize cars. $BR $BR $BBOLD (b) $EBOLD \{ $radio_samp_dist_mean->print_q() \} \{ $radio_samp_dist_mean->print_a() \} $BR $BR $BBOLD (c) $EBOLD The value for the mean of the sampling distribution is: \{ ans_rule(5) \}. $BR $BR $BBOLD (d) $EBOLD \{ $radio_dist->print_q() \} \{ $radio_dist->print_a() \} $BR \{ $radio_dist_reason->print_q() \} \{ $radio_dist_reason->print_a() \} $BR $BR $BBOLD (e) $EBOLD State the decision rule: $BR $BR Reject \(H_0\) at \( \alpha \)= \{ ans_rule(5) \}% if the p-value of the sample statistic is \{ $popup_p_value->menu() \}. $BR $BR $BBOLD (f) Experiment $EBOLD $BR \{ $radio_samp_stat->print_q() \} \{ $radio_samp_stat->print_a() \} $BR Value of the sample statistic: \{ ans_rule(7) \} $SPACE P-value of the sample statistic $BITALIC rounded to 4 decimal places$EITALIC: \{ ans_rule(5) \} $BR $BR $BBOLD (g) Conclusion $EBOLD $BR \{ $popup_conclusion->menu() \} at \( \alpha \)= \{ ans_rule(5) \}% $BR $BR $BBOLD (h) Answer the question $EBOLD $BR \{ $radio_answer->print_q() \} \{ $radio_answer->print_a() \} $BR $BR END_TEXT Context("Numeric"); WEIGHTED_ANS( $popup_H0_direction->cmp(),3 ); WEIGHTED_ANS( $popup_H0_mean->cmp(),3 ); WEIGHTED_ANS( $popup_Ha_mean1->cmp(),3 ); WEIGHTED_ANS( $popup_Ha_direction->cmp(),3 ); WEIGHTED_ANS( $popup_Ha_mean2->cmp(),4 ); WEIGHTED_ANS( radio_cmp( $radio_samp_dist_mean->correct_ans() ), 6 ); WEIGHTED_ANS($mean_samp_dist->cmp(tolType=>'absolute',tolerance=>0), 6); WEIGHTED_ANS( radio_cmp( $radio_dist->correct_ans() ), 6 ); WEIGHTED_ANS( radio_cmp( $radio_dist_reason->correct_ans() ), 6 ); WEIGHTED_ANS($alpha->cmp(tolType=>'absolute',tolerance=>0), 3); WEIGHTED_ANS( $popup_p_value->cmp(),6 ); WEIGHTED_ANS( radio_cmp( $radio_samp_stat->correct_ans() ), 6 ); WEIGHTED_ANS($sample_stat->cmp(tolType=>'absolute',tolerance=>0), 10); WEIGHTED_ANS($p_value->cmp(tolType=>'absolute',tolerance=>0), 11); WEIGHTED_ANS( $popup_conclusion->cmp(),11 ); WEIGHTED_ANS($alpha->cmp(tolType=>'absolute',tolerance=>0), 3); WEIGHTED_ANS( radio_cmp( $radio_answer->correct_ans() ), 10 ); ENDDOCUMENT(); # This should be the last executable line in the problem.