[npl] / trunk / NationalProblemLibrary / Rochester / setStatistics7MultinomialContingency / ur_stt_7_6.pg Repository: Repository Listing bbplugincoursesdistsnplrochestersystemwww

# View of /trunk/NationalProblemLibrary/Rochester/setStatistics7MultinomialContingency/ur_stt_7_6.pg

Tue May 9 13:07:16 2006 UTC (7 years ago) by jjholt
File size: 2722 byte(s)
Added tags.


    1 ## DESCRIPTION
2 ##   Multinomial Contingency
3 ## ENDDESCRIPTION
4
5 ## KEYWORDS('Multinomial', 'Contingency', 'Hypothesis', 'Test Statistic', 'Critical Value')
6 ## Tagged by nhamblet
7
8 ## DBsubject('Statistics')
9 ## DBchapter('Hypothesis Testing')
10 ## DBsection('Multinomial Contingency')
11 ## Date('')
12 ## Author('')
13 ## Institution('Rochester')
14 ## TitleText1('')
15 ## EditionText1('')
16 ## AuthorText1('')
17 ## Section1('')
18 ## Problem1('')
19
20 DOCUMENT();        # This should be the first executable line in the problem.
21
23 "PG.pl",
24 "PGbasicmacros.pl",
25 "PGchoicemacros.pl",
27 "PGgraphmacros.pl",
28 "PGnumericalmacros.pl",
29 "PGstatisticsmacros.pl"
30 );
31
32 TEXT(beginproblem());
33 $showPartialCorrectAnswers = 1; 34 35$s = random(100,300,1);
36 $m[0] = random(int($s*0.13), int($s*0.25), 1); 37$w[0] = random(2,4,1);
38 $m[1] = random(int($s*0.25), int($s*0.33), 1); 39$w[1] = random(2,5,1);
40 $m[2] = random(int($s*0.1), int($s*0.15), 1); 41$w[2] = random(2,4,1);
42 $m[3] = random(int($s*0.05), int($s*0.10), 1); 43$w[3] = random(2,4,1);
44 $m[4] = random(int($s*0.1), int($s*0.15), 1); 45$w[4] = random(int($s*0.05), int($s*0.1), 1);
46
47 $row_tot_m =$m[0]+$m[1]+$m[2]+$m[3]+$m[4];
48 $row_tot_w =$w[0]+$w[1]+$w[2]+$w[3]+$w[4];
49 $total =$row_tot_m + $row_tot_w; 50 51$stat = 0;
52 for ($i=0;$i<5; $i++) { 53$col_tot[$i] =$m[$i] +$w[$i]; 54$ex_m[$i] =$row_tot_m * $col_tot[$i] / $total; 55$ex_w[$i] =$row_tot_w * $col_tot[$i] / $total; 56$stat = $stat + ($m[$i]-$ex_m[$i])**2/$ex_m[$i] + ($w[$i]-$ex_w[$i])**2/$ex_w[$i]; 57 } 58 59$alpha = random(0.01, 0.025, 0.015);
60
61 $crit = chisqrdistr(4,$alpha);
62
63 $mc = new_multiple_choice(); 64 65 @ans = ('Yes','No'); 66 67 if ($stat > $crit) {$tag = 0;} else {$tag = 1;} 68 69$mc -> qa('Is there sufficient evidence to warrant the rejection of the claim that the
70 gender of a professor is independent of the department?', $ans[$tag]);
71
72 $mc -> extra($ans[1-$tag]); 73 74 BEGIN_TEXT 75 76 The number of men and women among professors in Math, Physics, Chemistry, Linguistics, and 77 English departments of a certain college were counted, and the results are shown in the 78 table below. 79 80 \{begintable(6)\} 81 \{row('Dept.', 'Math', 'Physics', 'Chemistry', 'Linguistics','English')\} 82 \{row('Men',$m[0], $m[1],$m[2], $m[3],$m[4])\}
83 \{row('Women', $w[0],$w[1], $w[2],$w[3], $w[4])\} 84 \{endtable()\} 85 86 Test the claim that the gender of a professor is independent of the department. Use the 87 significance level $$\alpha = alpha$$$BR
88
89 The test statistic is $$\chi^2=$$ \{ans_rule(10)\} $BR 90 91 The critical value is $$\chi^2=$$ \{ans_rule(10)\}$BR
92
93 \{$mc->print_q()\}$BR
94 \{$mc->print_a()\}$BR
95
96 END_TEXT
97
98 ANS(num_cmp($stat)); 99 ANS(num_cmp($crit));