From f720e140259879dae0ec644e0bd64d3df444c7b3 Mon Sep 17 00:00:00 2001 From: Peter Staab Date: Fri, 26 Jan 2024 13:11:07 -0500 Subject: [PATCH 1/2] create some new stats problems and updating some in the OPL On old problems, switch to newer graphics methods and PGML. Add solutions. --- .../Algebra/intervals/graphing-intervals.pg | 51 ++++++++ .../Probability/contingency_table.pg | 58 +++++++++ Contrib/Fitchburg/Probability/discrete_pdf.pg | 89 +++++++++++++ Contrib/Fitchburg/Probability/living.pg | 6 +- .../Fitchburg/Probability/proportions-pets.pg | 45 +++++++ .../Probability/siblings_rel_freq.pg | 73 +++++++++++ Contrib/Fitchburg/Probability/tree-diagram.pg | 77 ++++++++++++ .../Statistics/Basics/basic-definitions.pg | 110 ++++++++++++++++ .../Basics/definition-population.pg | 47 +++++++ .../Statistics/Descriptive/line-graph.pg | 54 ++++++++ .../Statistics/Descriptive/stem-leaf.pg | 62 +++++++++ .../41IntAlg_04_LinearIneq.pg | 119 +++++++----------- .../41IntAlg_05_LinearIneq.pg | 68 ++++------ .../01Stats_07_pictDistnsWGraphs.pg | 96 ++++++++++++++ .../01Stats_08_PictDistnsWGraphs.pg | 101 +++++++++++++++ .../01Stats_08_PictDistnsWGraphs.pg | 111 ---------------- .../01Stats_08_PictDistnsWGraphs/Ref_1_4.gif | Bin 3063 -> 0 bytes .../02Stats_01_DescrData.pg | 92 ++++++++++++++ .../02Stats_01_DescrData.pg | 88 ------------- .../02Stats_01_DescrData/3-118225.gif | Bin 4521 -> 0 bytes .../02Stats_01_DescrData/3-413210.gif | Bin 4651 -> 0 bytes .../setProbability7RandomVariables/p1.pg | 103 +++++++++------ .../ur_pb_7_3.pg | 114 ++++++++--------- .../setStatistics2Measures/ur_stt_2_4.pg | 96 +++++++------- 24 files changed, 1192 insertions(+), 468 deletions(-) create mode 100644 Contrib/Fitchburg/Algebra/intervals/graphing-intervals.pg create mode 100644 Contrib/Fitchburg/Probability/contingency_table.pg create mode 100644 Contrib/Fitchburg/Probability/discrete_pdf.pg create mode 100644 Contrib/Fitchburg/Probability/proportions-pets.pg create mode 100644 Contrib/Fitchburg/Probability/siblings_rel_freq.pg create mode 100644 Contrib/Fitchburg/Probability/tree-diagram.pg create mode 100644 Contrib/Fitchburg/Statistics/Basics/basic-definitions.pg create mode 100644 Contrib/Fitchburg/Statistics/Basics/definition-population.pg create mode 100644 Contrib/Fitchburg/Statistics/Descriptive/line-graph.pg create mode 100644 Contrib/Fitchburg/Statistics/Descriptive/stem-leaf.pg create mode 100644 OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_07_pictDistnsWGraphs.pg create mode 100644 OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_08_PictDistnsWGraphs.pg delete mode 100644 OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_08_PictDistnsWGraphs/01Stats_08_PictDistnsWGraphs.pg delete mode 100644 OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_08_PictDistnsWGraphs/Ref_1_4.gif create mode 100644 OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch02DescribingData/02Stats_01_DescrData.pg delete mode 100644 OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch02DescribingData/02Stats_01_DescrData/02Stats_01_DescrData.pg delete mode 100644 OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch02DescribingData/02Stats_01_DescrData/3-118225.gif delete mode 100644 OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch02DescribingData/02Stats_01_DescrData/3-413210.gif diff --git a/Contrib/Fitchburg/Algebra/intervals/graphing-intervals.pg b/Contrib/Fitchburg/Algebra/intervals/graphing-intervals.pg new file mode 100644 index 0000000000..e2cb9cf267 --- /dev/null +++ b/Contrib/Fitchburg/Algebra/intervals/graphing-intervals.pg @@ -0,0 +1,51 @@ +## DESCRIPTION +## Graphing intervals and linear inequalities +## ENDDESCRIPTION + +## DBsubject(Probability) +## DBchapter(Random variables) +## DBsection(Discrete: probability mass function) +## Institution(Fitchburg State) +## Author(Peter Staab) +## Date(02/10/2024) +## KEYWORDS('inequalities', 'number line graph', 'intervals') + +DOCUMENT(); + +loadMacros('PGstandard.pl', 'PGML.pl', 'parserGraphTool.pl', 'PGcourse.pl'); + +$x1 = random(1, 5); + +$gt1 = GraphTool("{interval, (-$x1,$x1]}")->with( + availableTools => + [ 'IntervalTool', 'IncludeExcludePointTool' ], + numberLine => 1, + bBox => [ -6, 6 ], + ticksDistanceX => 1, + minorTicksX => 0, + useBracketEnds => 0 +); + +$x2 = random(-5, 5); + +$gt2 = GraphTool("{interval, (-inf,$x2)}")->with( + availableTools => + ['IntervalTool', 'IncludeExcludePointTool' ], + numberLine => 1, + bBox => [ -6, 6 ], + ticksDistanceX => 1, + minorTicksX => 0, + useBracketEnds => 0 +); + +BEGIN_PGML +Graph the solution set for the interval [`(-[$x1],[$x1]]`]. + +[_]{$gt1} + +Graph the solution set for the linear inequality [`x < [$x2]`]. + +[_]{$gt2} +END_PGML + +ENDDOCUMENT(); \ No newline at end of file diff --git a/Contrib/Fitchburg/Probability/contingency_table.pg b/Contrib/Fitchburg/Probability/contingency_table.pg new file mode 100644 index 0000000000..4ef85d6705 --- /dev/null +++ b/Contrib/Fitchburg/Probability/contingency_table.pg @@ -0,0 +1,58 @@ +## DESCRIPTION +## Filling in a contingency table and answering probability questions based on it. +## +## ENDDESCRIPTION + +## DBsubject(Probability) +## DBchapter(Sample Space) +## DBsection(Probability: direct computation, inclusion/exclusion) +## Institution(Fitchburg State University) +## Author(Peter Staab) +## Level(1) + +DOCUMENT(); +loadMacros('PGstandard.pl', 'PGML.pl', 'niceTables.pl', 'contextPercent.pl', 'PGcourse.pl'); + +Context('Percent'); + +do { + $stream = random(35,65,5); + + $ssports = random(10,25); + $stv = random(5,15); + $smovie = random(10,20); + $sother = $stream - $ssports - $stv -$smovie; +} until $sother > 5; +$not_stream = 100 - $stream; +do { + $nsports = random(10,20); + $ntv = random(5,15); + $nmovie = random(10,20); + $nother = $not_stream- $nsports - $ntv -$nmovie; + } until $nother > 3; + + +$tab = DataTable([ + [ '', 'Sports', 'TV series', 'movies', 'other', 'total'], + [ 'Stream', $ssports, PGML('[_]{$stv}'), $smovie, $sother, $stream], + [ "Don't Stream", $nsports, $ntv, PGML('[_]{$nmovie}'), PGML('[_]{$nother}'), PGML('[_]{$not_stream}')], + ['Total', PGML('[_]{Real($ssports+$nsports)}'), PGML('[_]{Real($stv+$ntv)}'), $smovie+$nmovie, PGML('[_]{$nother+$sother}'), 100] + ], horizontalrules => 1, align => '|r|r|r|r|r|r|' + ); +BEGIN_PGML +One-hundred (100) people were surveyed about their video watching. They were asked about whether they stream or not and their primary watching preference. The following incomplete table was found: + +[$tab]* + +Complete the above table. + +If [`S`] is the event that a person prefers to stream videos, [`M`] is the event that a person prefers to watch movies and [`T`] is the event that a person prefers sports, if a person is selected randomly, find the following probabilities: + +a) [`P(T) = `] [_]{Real(($ssports+$nsports)/100)} +b) [`P(S\text{ and } T) = `] [_]{Real($ssports/100)} +c) [` P(S\text{ or } M) = `] [_]{Real(($stream + $nmovie)/100)} + + +END_PGML + +ENDDOCUMENT(); diff --git a/Contrib/Fitchburg/Probability/discrete_pdf.pg b/Contrib/Fitchburg/Probability/discrete_pdf.pg new file mode 100644 index 0000000000..57a1c45522 --- /dev/null +++ b/Contrib/Fitchburg/Probability/discrete_pdf.pg @@ -0,0 +1,89 @@ +# DESCRIPTION +# A problem that asks students to ... +# +# Modified for WeBWorK by Michael Stassen mstassen(at)fitchburgstate(dot)edu +# ENDDESCRIPTION + +## DBsubject('Introductory Statistics') +## DBchapter('1') +## DBsection('2') +## KEYWORDS('') +## TitleText1('') +## EditionText1('') +## AuthorText1('') +## Section1('') +## Problem1('') +## Author('Michael Stassen') +## Institution('Fitchburg State University') + +DOCUMENT(); +loadMacros( + "PGstandard.pl", "PGML.pl", + "contextPercent.pl", "niceTables.pl", + 'PGcourse.pl' +); + +Context("Percent"); +@p = ( + random(.001, .004, .001), + random(.002, .005, .001), + random(.001, .004, .001), + random(.065, .095, .010), + random(.075, .105, .010), + random(.105, .135, .010), + random(.205, .235, .010), + 0, + random(.100, .200, .050), + random(.075, .125, .025), + random(.040, .060, .010) +); +$s = 0; +$s += $_ for (@p); +$p[7] = 1 - $s; + +@PDF = ([ '\(x\)', '\(P(X=x)\)' ]); + +for $x (0 .. 10) { + my $p = sprintf("%0.3f", $p[$x]); + push(@PDF, [ $x, $p ]); +} + +$x1 = random(3,8); +$p1 = $p[$x1]; +$x2 = random(1,4); +$p2 = 0; +$p2 += $_ for(@p[0..($x2-1)]); +$p3 = 0; +$p3 += $_ for(@p[0..$x2]); +$x4 = random(7,9); +$p4 = 0; +$p4 += $_ for(@p[$x4..$#p]); + +BEGIN_PGML +Use the PDF for the random variable, [`X`] = _score on quiz_, to answer the questions. + +[@ DataTable( + [ @PDF ], + align => '|c|c|', + horizontalrules => 1) +@]* +END_PGML + +BEGIN_PGML +a) [`P(X=[$x1])`] = [____]{Percent($p1)} +b) [`P(X<[$x2])`] = [____]{Percent($p2)} +c) [`P(X \le [$x2])`] = [____]{Percent($p3)} +d) [`P(X \ge [$x4])`] = [____]{Percent($p4)} +e) [`P(X \ge 1)`] = [____]{Percent(1-$p[0])} +END_PGML + +BEGIN_PGML_SOLUTION +a) In this case, read the probabilty off the [`X=[$x1]`] line or [$p1] (or [@ Percent($p1)@]). +b) In this case, add up all of the probabilities for the line above the [`X=[$x2]`] line. This is [$p2] or ([@ Percent($p2) @]). +c) In this case, add up all of the probabilities for the line at and above the [`X=[$x2]`] line. This is [$p3] or ([@ Percent($p3) @]). +d) In this case, add up all o fthe probabilite for the line at and below the [`X=[$x4]`] +line. This is [$p4] or [@ Percent ($p4) @]). +e) In this case, it is easiest to recall that the sum of all of the probabilities must be 1. Therefore, this is the same as [`1-P(X<1)`] which is [@ 1-$p[0] @] or [@ Percent(1-$p[0]) @] +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/Fitchburg/Probability/living.pg b/Contrib/Fitchburg/Probability/living.pg index c1acbef1da..30038ac58a 100644 --- a/Contrib/Fitchburg/Probability/living.pg +++ b/Contrib/Fitchburg/Probability/living.pg @@ -47,9 +47,9 @@ One hundred nurses were surveyed about their living situation. The results of th >> [@ DataTable([ - ['',PGML('_Renter_ (`R`)'), PGML('_Homeowner_ ([`R^{\prime}`])'), PGML('_Total_')], - [PGML('Lives Alone (`A`)'),$a,$b,'50'], - [PGML('Does not live alone (`A^{\prime}`)'), $c, $d, '50'], + ['',PGML('_Renter_ ([`R`])'), PGML('_Homeowner_ ([`R^{\prime}`])'), PGML('_Total_')], + [PGML('Lives Alone [`A`]'),$a,$b,'50'], + [PGML('Does not live alone [`A^{\prime}`]'), $c, $d, '50'], [PGML('Total'), $e, $f, 100] ], padding => [0.5, 0.5], diff --git a/Contrib/Fitchburg/Probability/proportions-pets.pg b/Contrib/Fitchburg/Probability/proportions-pets.pg new file mode 100644 index 0000000000..59f07f2379 --- /dev/null +++ b/Contrib/Fitchburg/Probability/proportions-pets.pg @@ -0,0 +1,45 @@ +## DESCRIPTION +## Statistics: Descriptive statistics +## ENDDESCRIPTION + +## Tagged by CTD + +## DBsubject(Statistics) +## DBchapter(Exploratory data analysis/descriptive statistics) +## DBsection(Summary statistics) +## Date(8/15/12) +## Institution(Fitchburg State) +## Author(Jessie Oehrlein) +## Level(2) +## KEYWORDS('proportions','sample proportion') + +DOCUMENT(); + +loadMacros("PGstandard.pl", "Parser.pl", "Stats.pl", "PGML.pl"); + +Context("LimitedNumeric"); + +$n = random(100, 1000, 100); +$p = random(10, 90, 10); +$pprop = $p / 100; +$offset = random(-5, 5, 1); +$phat = $p + $offset; +$phatprop = $phat / 100; +$x = $phatprop * $n; + +BEGIN_PGML +Overall, [$p] percent of students at Mythic University have pets. [$n] randomly selected students at were asked whether they have pets, and [$x] of them said that they did. + +Enter each requested value. Proportions should be entered with two decimal points of precision. + +[` n `] = [_]{$n} + +[` x `] = [_]{$x} + +[` p `] = [_]{$pprop} + +[` \hat{p} `] = [_]{$phatprop} + +END_PGML + +ENDDOCUMENT(); diff --git a/Contrib/Fitchburg/Probability/siblings_rel_freq.pg b/Contrib/Fitchburg/Probability/siblings_rel_freq.pg new file mode 100644 index 0000000000..de18a9b2b0 --- /dev/null +++ b/Contrib/Fitchburg/Probability/siblings_rel_freq.pg @@ -0,0 +1,73 @@ +DOCUMENT(); + +loadMacros("PGstandard.pl", "PGML.pl", "niceTables.pl", "contextPercent.pl"); + +Context("LimitedNumeric"); +loadMacros("fixedPrecision.pl"); # must come after Context is set. + +$total = random(40, 50, 10); + +@freq = + (random(5, 9), random(7, 13), 0, random(3, 5), random(2, 3), random(1, 2)); +$subtotal = 0; +$subtotal += $_ for (@freq); +$freq[2] = $total - $subtotal; + +@rf = map { FixedPrecision($_ / $total, 3); } @freq; + +$crf[0] = FixedPrecision(100 * $rf[0], 1); +for $i (1 .. 5) { + $crf[$i] = FixedPrecision($crf[ $i - 1 ] + 100 * $rf[$i], 1); +} + +BEGIN_PGML +[$total] students were surveyed. The number of siblings for each student was recorded. The data is summarized in the following table: + +[@ DataTable( + [ + [['Siblings', headerrow=>1], 'Relative Frequency'], + [0, $rf[0]], + [1, $rf[1]], + [2, $rf[2]], + [3, $rf[3]], + [4, $rf[4]], + [5, $rf[5]], + ], + align => '|c|c|', + horizontalrules => 1 + ) + @]* + +END_PGML + +$s = random(2, 4); + +Context("LimitedPercent-strict"); +Context()->flags->set(forceDecimals => 1); + +$pS = Percent(FixedPrecision(100 * $rf[$s], 1) . '%'); +$pLeast = Percent(FixedPrecision(100 - $crf[ $s - 1 ], 1) . '%'); +$pFewer = Percent(FixedPrecision($crf[ $s - 1 ], 1) . '%'); +$pMost = Percent(FixedPrecision($crf[$s], 1) . '%'); +$pMore = Percent(FixedPrecision(100 - $crf[$s], 1) . '%'); + +BEGIN_PGML +Answer the questions with percents (including the percent sign) and round to one digit past the decimal. + +a) What percent of the students have [$s] siblings? [_____]{$pS} +b) What percent of the students have at least [$s] siblings? [_____]{$pLeast} +c) What percent of the students have fewer than [$s] siblings? [_____]{$pFewer} +d) What percent of the students have at most [$s] siblings? [_____]{$pMost} +e) What percent of the students have more than [$s] siblings? [_____]{$pMore} + +END_PGML + +BEGIN_PGML_SOLUTION +a) In this case, convert the relative frequency in the row with [$s] siblings to a percent. This is [$pS] +b) Sum the relative frequencies in the row with [$s] siblings and below then convert to a percent. This is [$pLeast]. +c) Sum the relative frequencies in the row above the [$s] siblings, then convert to a percent. This is [$pFewer]. +d) Sum the relative frequencies from the top to the row with [$s] siblings, then convert to a percent. This is [$pMost]. +e) Sum the relative frequencies from below the row with [$s] siblings, then convert to a percent. This is [$pMore]. +END_PGML_SOLUTION + +ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/Contrib/Fitchburg/Probability/tree-diagram.pg b/Contrib/Fitchburg/Probability/tree-diagram.pg new file mode 100644 index 0000000000..de800c1bf8 --- /dev/null +++ b/Contrib/Fitchburg/Probability/tree-diagram.pg @@ -0,0 +1,77 @@ +## DESCRIPTION +## Calculate probabilities of selecting marbles from a bag using a tree diagram. +## +## ENDDESCRIPTION + +## DBsubject(Probability) +## DBchapter(Sample Space) +## DBsection(Probability: direct computation, inclusion/exclusion) +## Institution(Fitchburg State University) +## Author(Peter Staab) +## Level(1) + +DOCUMENT(); +loadMacros('PGstandard.pl', 'PGML.pl', 'PGtikz.pl', 'contextPercent.pl', 'PGcourse.pl'); + +Context('Numeric'); + +$red = random(2,4); +$green = random(5,7); + +$graph = createTikZImage(); +$graph->tikzLibraries('arrows.meta'); +$graph->BEGIN_TIKZ +\tikzset{>={Stealth[scale=1.5]}} +\filldraw[ + draw=LightBlue, + fill=white, + rounded corners=10pt, + thick,use as bounding box +] (0,0.5) rectangle (6,6); +\draw(3,6) -- (1.5,4.5) node[below] {a R}; +\draw(3,6) -- (4.5,4.5) node[below] {b G}; +\draw(1.5,4) -- (0.5,3) node[below] {c R}; +\draw(1.5,4) -- (2.2,3) node[below] {d G}; +\draw(4.5,4) -- (3.8,3) node [below] {e R}; +\draw(4.5,4) -- (5.5,3) node [below] {f G}; +\draw(0.5,2.5) -- (0.5,1.5) node [below] {g RR}; +\draw(2.2,2.5) -- (2.2,1.5) node [below] {h RG}; +\draw(3.8,2.5) -- (3.8,1.5) node [below] {i GR}; +\draw(5.5,2.5) -- (5.5,1.5) node [below] {j GG}; +END_TIKZ + +Context('Percent'); + +$ans1 = Real(($red/($red+$green))**2); +$ans2 = Real(2*$red*$green/($red+$green)**2); + +BEGIN_PGML +A bag contains [$red] red and [$green] green marbles. Marbles are selected randomly from +the bag *with* replacement. + +Consider the following tree diagram + +[! !]{$graph}{400} + +where [`a, b, c, d, e, f, g, h, i`] and [`j`] are whole numbers. Based on this problem, find these numbers; + +a) [_]{Real($red)} +b) [_]{Real($green)} +c) [_]{Real($red)} +d) [_]{Real($green)} +e) [_]{Real($red)} +f) [_]{Real($green)} +g) [_]{Real($red*$red)} +h) [_]{Real($green*$red)} +i) [_]{Real($green*$red)} + +j: [_]{Real($red*$red)} + +Also, calclulate the following: + +a) [`P(RR) = `] [_]{Real($ans1)} +b) [`P(RG\text{ or } GR) = `] [_]{Real($ans2)} + +END_PGML + +ENDDOCUMENT(); diff --git a/Contrib/Fitchburg/Statistics/Basics/basic-definitions.pg b/Contrib/Fitchburg/Statistics/Basics/basic-definitions.pg new file mode 100644 index 0000000000..cb64686558 --- /dev/null +++ b/Contrib/Fitchburg/Statistics/Basics/basic-definitions.pg @@ -0,0 +1,110 @@ +# DESCRIPTION +# A problem that asks students to determine the population, variable, +# data, sample, statistic and parameter from a situation. +# +# This problem is derived from a homework problem in Introductory Statistics, +# licensed by OpenStax under a Creative Commons Attribution License (CC BY 4.0). +# Modified for WeBWorK by Michael Stassen mstassen(at)fitchburgstate(dot)edu +# ENDDESCRIPTION + +## DBsubject(Statistics) +## DBchapter(Experimental design) +## DBsection(Concepts) +## Institution(Fitchburg State University) +## Author(Michael Stassen) + +DOCUMENT(); + +loadMacros( +"PG.pl", +"PGbasicmacros.pl", +"PGchoicemacros.pl", +"PGanswermacros.pl", +"unionTables.pl", +"PGML.pl", +); + +TEXT(beginproblem()); +$ml = new_match_list(); +$ml->qa( +"Population", "All clients of the fitness center", +"Variable", "Amount of time a client exercises in the center in a week", +"Sample", "The 50 randomly selected clients", +"Parameter", "The mean amount of time a client exercises in the center per week", +"Data", "The 50 recorded amounts of time", +"Statistic", "The mean amount of time the 50 selected clients exercise in the center per week" +); + +# use pop-up-lists +$ml->rf_print_q(~~&pop_up_list_print_q); +# you may need to add more letters D=>"D", etc. +$ml->ra_pop_up_list([No_answer=>"?",A=>"A",B=>"B",C=>"C", D=>"D", E=>"E",F=>"F", G=>"G",H=>"H", I=>"I"]); +$ml->choose(6); + +$ml->extra("People who exercise", "All clients of fitness centers", ); +$ml->choose_extra(2); + +$ml->makeLast("None of the above"); + +BEGIN_PGML +A fitness center is interested in the mean amount of time a client exercises in the center per week. They randomly select 50 clients and record their time spent exercising for a week. +Match each term with the corresponding part of the study. +[@ ColumnMatchTable($ml) @]*** +END_PGML + + +# no credit until all answers are correct +install_problem_grader(~~&std_problem_grader); +$showPartialCorrectAnswers = 1; + +ANS( str_cmp( $ml->ra_correct_ans ) ); + +# the remainder of the code is included to +# provide a sensible solution for the +# student. + +# the answers to the questions that were +# asked, in order, are +@correctAns = @{$ml->ra_correct_ans}; + +# the following becomes necessary if we want +# to figure out what questions were asked +# so that we can give explanations for +# them. +# it's useful to define an array of +# explanations that correspond to the +# list of questions we might have asked +@explanations = ( +"the population is the complete group of interest", +"each member of the population or sample has a value of the variable", +"the sample is the selected subset of the population", +"a parameter is a descriptive measure of the population", +"the data is the set of recorded values of the variable", +"a statistic is a descriptive measure of the sample data" +); + +# then find the questions that were asked +@askedQuestions = (); +foreach $q ( @{$ml->selected_q} ) { + $i = 0; + foreach $mq ( @{$ml->questions} ) { + if ( $q eq $mq ) { + push(@askedQuestions, $i); + last; + } + $i++; + } +} +BEGIN_PGML_SOLUTION +1. The answer is [$correctAns[0]], because [$explanations[$askedQuestions[0]]]. +2. The answer is [$correctAns[1]], because [$explanations[$askedQuestions[1]]]. +3. The answer is [$correctAns[2]], because [$explanations[$askedQuestions[2]]]. +4. The answer is [$correctAns[3]], because [$explanations[$askedQuestions[3]]]. +5. The answer is [$correctAns[4]], because [$explanations[$askedQuestions[4]]]. +6. The answer is [$correctAns[5]], because [$explanations[$askedQuestions[5]]]. + +END_PGML_SOLUTION + +COMMENT('This problem is derived from an OpenStax problem'); + +ENDDOCUMENT(); diff --git a/Contrib/Fitchburg/Statistics/Basics/definition-population.pg b/Contrib/Fitchburg/Statistics/Basics/definition-population.pg new file mode 100644 index 0000000000..f7b07dc8c3 --- /dev/null +++ b/Contrib/Fitchburg/Statistics/Basics/definition-population.pg @@ -0,0 +1,47 @@ +# DESCRIPTION +# A problem that asks students to determine which group of student is the population. + +# This problem is derived from a homework problem in Introductory Statistics, +# licensed by OpenStax under a Creative Commons Attribution License (CC BY 4.0). +# Modified for WeBWorK by Michael Stassen mstassen(at)fitchburgstate(dot)edu +# ENDDESCRIPTION + +## DBsubject(Statistics) +## DBchapter(Experimental design) +## DBsection(Concepts) +## Institution(Fitchburg State University) +## Author(Michael Stassen) + +DOCUMENT(); + +loadMacros('PGstandard.pl', 'PGML.pl', 'parserRadioButtons.pl', 'PGcourse.pl'); +$showPartialCorrectAnswers = 0; #No guessing +$cc = 'Springfield Community College'; + +$mc = RadioButtons( + [ + "all $cc students", + "all $cc English students", + "all $cc students in her classes", + "all $cc math students" + ], + "all $cc math students", + labels => "ABC" +); + +BEGIN_PGML +A [$cc] instructor is interested in the mean number of days [$cc] +math students are absent from class during a semester. + +What is the population she is interested in? + +[_]{$mc} + +END_PGML + +BEGIN_PGML_SOLUTION +The population is the group of student that the research wants to study. In this case, it is all [$cc] math students. +END_PGML_SOLUTION + +COMMENT('This was derived from an OpenStax problem'); +ENDDOCUMENT(); diff --git a/Contrib/Fitchburg/Statistics/Descriptive/line-graph.pg b/Contrib/Fitchburg/Statistics/Descriptive/line-graph.pg new file mode 100644 index 0000000000..3c66be13e0 --- /dev/null +++ b/Contrib/Fitchburg/Statistics/Descriptive/line-graph.pg @@ -0,0 +1,54 @@ +## DESCRIPTION +## Give a value for pi +## ENDDESCRIPTION + +## KEYWORDS('template', 'pi') + +## DBsubject('Algebra') +## DBchapter('Fundamentals') +## DBsection('Real Numbers') +## Date('') +## Author('') +## Institution('') + +DOCUMENT(); + +loadMacros('PGstandard.pl','PGML.pl','parserGraphTool.pl','randomPerson.pl', 'niceTables.pl', 'PGcourse.pl'); + +$p_first = randomPerson(); +$p_last = randomLastName(); + +@q = (random(1,3), random(2,4), random(2,5), random(3,6), random(2,7), random(0,3)); + +$tab = DataTable([ + [['Number of Correct Questions' , rowheader => 1], 'Number of Students'], + map { [$_, $q[$_]] } (0..5) + ] + ); + +$str = join ', ', map { "{point, ($_, $q[$_])}" } (0..5); + +$gt = GraphTool($str)->with( + availableTools => ['PointTool'], + bBox => [ -1, 6, 6, -1 ], + showCoordinateHints => 0, +); + +BEGIN_PGML +Professor [$p_last] [@ $p_first->verb('give') @] [$p_first->their] class a pop quiz with 5 questions. The number of students who answer the correct number of questions is given in the following table. + +[$tab]* + +Construct a line graph below using the point below. Note: the line will not be drawn +between the points. + +[_]{$gt} + + +END_PGML + +BEGIN_PGML_SOLUTION +[@ $gt->generateAnswerGraph @]* +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/Fitchburg/Statistics/Descriptive/stem-leaf.pg b/Contrib/Fitchburg/Statistics/Descriptive/stem-leaf.pg new file mode 100644 index 0000000000..1a337fa6fb --- /dev/null +++ b/Contrib/Fitchburg/Statistics/Descriptive/stem-leaf.pg @@ -0,0 +1,62 @@ +## DESCRIPTION +## Give a value for pi +## ENDDESCRIPTION + +## KEYWORDS('template', 'pi') + +## DBsubject('Algebra') +## DBchapter('Fundamentals') +## DBsection('Real Numbers') +## Date('') +## Author('') +## Institution('') + +DOCUMENT(); + +loadMacros('PGstandard.pl', 'PGML.pl', 'niceTables.pl', 'PGcourse.pl'); + +@x = map { random(20, 65) } (1 .. 30); + +@leaf2 = num_sort(map { $_ % 10 } grep { 20 <= $_ && $_ < 30 } @x); +@leaf3 = num_sort(map { $_ % 10 } grep { 30 <= $_ && $_ < 40 } @x); +@leaf4 = num_sort(map { $_ % 10 } grep { 40 <= $_ && $_ < 50 } @x); +@leaf5 = num_sort(map { $_ % 10 } grep { 50 <= $_ && $_ < 60 } @x); +@leaf6 = num_sort(map { $_ % 10 } grep { 60 <= $_ && $_ < 70 } @x); + +$tab = DataTable([ + [ [ 'stem', headerrow => 1 ], 'leaf' ], + [ 2, PGML('[_]{List(@leaf2)->cmp(ordered => 1)}') ], + [ PGML('[_]{Real(3)}'), PGML('[_]{List(@leaf3)->cmp(ordered => 1)}') ], + [ PGML('[_]{Real(4)}'), PGML('[_]{List(@leaf4)->cmp(ordered => 1)}') ], + [ PGML('[_]{Real(5)}'), PGML('[_]{List(@leaf5)->cmp(ordered => 1)}') ], + [ 6, PGML('[_]{List(@leaf6)->cmp(ordered => 1)}') ], +]); + +BEGIN_PGML +Consider the dataset +[``` [@ join(', ',@x) @] ```] + +Fill in the following stem and leaf plot: + +[$tab]* + +The numbers in the leaves should be ordered and separated by commas. +END_PGML + +$sol_table = DataTable([ + [ [ 'stem', headerrow => 1 ], 'leaf' ], + [ 2, join(', ', @leaf2) ], + [ 3, join(', ', @leaf3) ], + [ 4, join(', ', @leaf4) ], + [ 5, join(', ', @leaf5) ], + [ 6, join(', ', @leaf6) ], +]); + +BEGIN_PGML_SOLUTION +Recall for a Stem and Leaf plot, the stem is the first digit and the leaves are the second +digit. In this case, + +[$sol_table]* +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/OpenProblemLibrary/CollegeOfIdaho/setAlgebra_04_01_LinearInequalities/41IntAlg_04_LinearIneq.pg b/OpenProblemLibrary/CollegeOfIdaho/setAlgebra_04_01_LinearInequalities/41IntAlg_04_LinearIneq.pg index 5253690196..72689ed3a6 100644 --- a/OpenProblemLibrary/CollegeOfIdaho/setAlgebra_04_01_LinearInequalities/41IntAlg_04_LinearIneq.pg +++ b/OpenProblemLibrary/CollegeOfIdaho/setAlgebra_04_01_LinearInequalities/41IntAlg_04_LinearIneq.pg @@ -1,12 +1,13 @@ ##DESCRIPTION ## Linear Inequalities -## + ##ENDDESCRIPTION ## DBsubject(Algebra) ## DBchapter(Algebra of real numbers and simplifying expressions) ## DBsection(Inequalities and intervals) ## Institution(The College of Idaho) ## Author(RA Cruz) +## Date(10/01/2007) ## MLT(Graph_to_interval) ## MLTleader(1) ## MO(1) @@ -16,84 +17,56 @@ ## Section1('4.1') ## Problem1('') ## KEYWORDS('inequalities') -## Date: 2007/10 -DOCUMENT(); # This should be the first executable line in the problem. +# Updated by Peter Staab (Fitchburg State) on 2024.01.22 -loadMacros( - "PGstandard.pl", - "PGchoicemacros.pl", - "MathObjects.pl", - "PGgraphmacros.pl", - "PGnauGraphics.pl", - "contextInequalitiesAllowStrings.pl", - "answerHints.pl", - "CofIdaho_macros.pl", - "PGcourse.pl" -); +DOCUMENT(); # This should be the first executable line in the problem. -TEXT(beginproblem()); +loadMacros('PGstandard.pl', 'PGML.pl', 'PGtikz.pl', 'PGcourse.pl'); -###################################### # Setup -Context("Inequalities-AllowStrings"); - -$a = random(-5,1,1); -$b = $a + random(1,4,1); -@interval = (Interval("[$a,$b]"),Interval("($a,$b)")); -$choose = random(0,1,1); - -@slice = NchooseK(3,3); -@colors = ("blue", "red", "green"); -@sc = @colors[@slice]; #scrambled colors - -$graph = init_graph(-6,-1,6,1,'pixels'=>[300,50]); - -$graph->moveTo(-6,0); #Draw x-axis and tick marks -$graph->lineTo(6,-0); -$i = -5; -do { - $lab=new Label($i,-.5,"$i",'black','center','center'); - $graph->lb($lab); - $graph->moveTo($i,.25); - $graph->lineTo($i,-.25); - $i++; -} until ($i > 5); - -$f = FEQ("0 for x in $interval[$choose] using color=$sc[0] and weight=3"); -add_functions( $graph,$f); - -###################################### -# Main text +Context("Interval"); + +$a = random(-5,1); +$b = $a + random(1,4); +$r1 = random(0,1); +$left = $r1 ? '[' : '('; +$left_sym = ($r1 ? '\fill' : '\draw') . "[blue]($a,0) circle[radius=3pt];"; + +$r2 = random(0,1); +$right = $r2 ? ']' : ')'; +$right_sym = ($r2 ? '\fill' : '\draw') . "[blue]($b,0) circle[radius=3pt];"; + +$sol = Interval("$left$a,$b$right"); + +$graph = createTikZImage(); +$graph->tikzLibraries('arrows.meta'); +$graph->BEGIN_TIKZ +\tikzset{>={Stealth[scale=1.5]}} +\filldraw[ + draw=LightBlue, + fill=white, + rounded corners=10pt, + thick,use as bounding box +] (-6,-1) rectangle (6,1); +\draw[<->] (-6,0) -- (6,0); +\draw[blue, very thick] ($a,0) -- ($b,0); +$left_sym; +$right_sym; +\foreach \x in {-5,-4,...,1,1,2,...,5} \draw (\x,0.2) -- (\x,-0.2) node [scale=1.5, below] {\(\x\)}; +END_TIKZ + +$alt_text = "A graph of just the x-axis with a line segment from ($a,0) to ($b,0). " + . "At the left end is an " . ($r1 ? 'closed' : 'open') . ' circle. ' + . "At the right end is an " . ($r2 ? 'closed' : 'open') . ' circle.'; + + +BEGIN_PGML +>> [! [$alt_text] !]{$graph}{400} << -BEGIN_TEXT -\{ Plot($graph, tex_size => 600) \} -$BR $BR Express the inequality shown in the graph above using interval notation. -$PAR -Answer: \{ans_rule(25) \} -END_TEXT - -###################################### -# Answer - -Context()->strings->add("No solution"=>{}); - -ANS($interval[$choose]->cmp->withPostFilter(AnswerHints( - sub { - my ($correct,$student,$ans) = @_; - return $student =~ /[=><]/; - } => ["Enter your answer with interval notation.", - checkCorrect => 1, - score => 0] -))); - -$showPartialCorrectAnswers = 1; - -###################################### - - -; -ENDDOCUMENT(); +Answer: [_]{$sol} +END_PGML +ENDDOCUMENT(); \ No newline at end of file diff --git a/OpenProblemLibrary/CollegeOfIdaho/setAlgebra_04_01_LinearInequalities/41IntAlg_05_LinearIneq.pg b/OpenProblemLibrary/CollegeOfIdaho/setAlgebra_04_01_LinearInequalities/41IntAlg_05_LinearIneq.pg index 48351a7206..41cee10457 100644 --- a/OpenProblemLibrary/CollegeOfIdaho/setAlgebra_04_01_LinearInequalities/41IntAlg_05_LinearIneq.pg +++ b/OpenProblemLibrary/CollegeOfIdaho/setAlgebra_04_01_LinearInequalities/41IntAlg_05_LinearIneq.pg @@ -1,6 +1,6 @@ ##DESCRIPTION ## Linear Inequalities -## +## ##ENDDESCRIPTION ## DBsubject(Algebra) ## DBchapter(Algebra of real numbers and simplifying expressions) @@ -18,54 +18,32 @@ ## KEYWORDS('inequalities') ## Date: 2007/10 -DOCUMENT(); # This should be the first executable line in the problem. +DOCUMENT(); # This should be the first executable line in the problem. loadMacros( - "PGstandard.pl", - "PGchoicemacros.pl", - "MathObjects.pl", - "contextInequalitiesAllowStrings.pl", - "answerHints.pl", - "PGcourse.pl" + "PGstandard.pl", "PGML.pl", + "contextInequalitiesAllowStrings.pl", "answerHints.pl", + "PGcourse.pl" ); -TEXT(beginproblem()); - -###################################### -# Setup - -$a = random(-10,10,1); - -###################################### -# Main text - -BEGIN_TEXT +Context('Inequalities-AllowStrings'); + +$a = random(-10, 10, 1); +$ans = Interval("(-inf,$a)")->cmp->withPostFilter(AnswerHints( + sub { + my ($correct, $student, $ans) = @_; + return $student =~ /[=><]/; + } => [ + "Enter your answer with interval notation.", + checkCorrect => 1, + score => 0 + ] +)); + +BEGIN_PGML Express the inequality using interval notation. -\[ x<$a \] -Answer: \{ans_rule(20) \} -END_TEXT - -###################################### -# Answer - -Context("Inequalities-AllowStrings"); -Context()->strings->add("No solution"=>{}); +[``` x<[$a] ```] +Answer: [_]{$ans} +END_PGML -$ans = Interval("(-infinity,$a)"); -ANS($ans->cmp->withPostFilter(AnswerHints( - sub { - my ($correct,$student,$ans) = @_; - return $student =~ /[=><]/; - } => ["Enter your answer with interval notation.", - checkCorrect => 1, - score => 0] -))); - -$showPartialCorrectAnswers = 1; - -###################################### - - -; ENDDOCUMENT(); - diff --git a/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_07_pictDistnsWGraphs.pg b/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_07_pictDistnsWGraphs.pg new file mode 100644 index 0000000000..b88bfea8b8 --- /dev/null +++ b/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_07_pictDistnsWGraphs.pg @@ -0,0 +1,96 @@ +## DESCRIPTION +## DBsubject(Statistics) +## DBchapter(Exploratory data analysis/descriptive statistics) +## DBsection(Graphical representations) +## Institution(The College of Idaho) +## Author(R Cruz, L Danielson, J Guild) +## Level(1) +## TitleText1('The Basic Practice of Statistics') +## AuthorText1('David Moore') +## EditionText1('5e') +## Section1('1') +## Problem1('') +## KEYWORDS('statistics', 'quantitative data', 'categorical data', 'histogram') + +# updated by Peter Staab (Fitchburg State) on 2024.01.31 + +DOCUMENT(); + +loadMacros( + 'PGstandard.pl', 'PGML.pl', 'contextPercent.pl', + + 'PGtikz.pl', 'parserPopUp.pl', + 'PGstatisticsmacros.pl', 'PGcourse.pl' +); + +# generate some data is is skewed rigt + +@cutoffs = (59, 62, 65, 68, 71, 74, 77, 80); +do { +@norm_rands = urand(70, 5, 40, 1); +@h = (); +$max = 0; +for $i (0 .. $#cutoffs - 1) { + $h[$i] = scalar(grep { $_ >= $cutoffs[$i] && $_ < $cutoffs[ $i + 1 ] } + @norm_rands); + $max = $h[$i] if $h[$i]> $max; +} + +} until $max <=10; + +$num_students = 0; +$num_students += $h[$_] for (0 .. $#h); + +# generate the rectangles +$rects = ''; +for $i (0 .. $#h) { + $rects .= + "\\filldraw[fill=LightBlue] ({$cutoffs[$i]-59},0) rectangle ({$cutoffs[$i+1]-59},{$h[$i]});\n"; +} + +$xticks = join(', ', @cutoffs); +$graph = createTikZImage(); +$graph->tikzLibraries('arrows.meta'); +$graph->BEGIN_TIKZ +\tikzset{>={Stealth[scale=1.5]},xscale=0.5} +\filldraw[ + draw=LightBlue, + fill=white, + rounded corners=10pt, + thick,use as bounding box +] (-2,11.5) rectangle (22,-1); +$rects; +\draw (0,0) rectangle (21,11); +\foreach \x in {$xticks} \draw ({\x-59},0) -- ({\x-59},-0.25) node [below] {\x}; +\foreach \y in {1,2,...,11} \draw(0,{\y}) -- (-0.25,{\y}); +\foreach \y in {5,10} \draw (0,{\y}) -- (-0.5,{\y}) node [left] {\y}; +END_TIKZ + +$alt_text = "A histogram of the $num_students students. The cutoff values are " + . join(', ', @cutoffs) . ' and there are 7 bars. From left to right the ' + . "heights are " . join(', ', @h) . '.'; + +Context('Percent'); +$k = random(0,4); + +$inter = Percent(($h[$k]+$h[$k+1])/$num_students); +$dd = DropDown(['59-65','62-68','65-71','68-74','71-77','74-80'],$k); + + +$over74 = Percent(($h[5]+$h[6])/$num_students); + +BEGIN_PGML +The histogram below shows the heights of [$num_students] students. + +>> [! [$alt_text] !]{$graph}{400} << + +a) How many students are between 65 and 68 inches in height? [_]{Real($h[2])} + +b) What percent of students have height greater than 74 inches? [_]{$over74} + +c) Which interval is about [$inter] perecent of the students. [_]{$dd} + +Note: on b) include the % sign. +END_PGML + +ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_08_PictDistnsWGraphs.pg b/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_08_PictDistnsWGraphs.pg new file mode 100644 index 0000000000..67547eb1b7 --- /dev/null +++ b/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_08_PictDistnsWGraphs.pg @@ -0,0 +1,101 @@ +## DESCRIPTION +## DBsubject(Statistics) +## DBchapter(Exploratory data analysis/descriptive statistics) +## DBsection(Graphical representations) +## Institution(The College of Idaho) +## Author(R Cruz, L Danielson, J Guild) +## Level(1) +## TitleText1('The Basic Practice of Statistics') +## AuthorText1('David Moore') +## EditionText1('5e') +## Section1('1') +## Problem1('') +## KEYWORDS('statistics', 'quantitative data', 'categorical data', 'histogram') + +# Updated by Peter Staab (Fitchburg State) on 2024.01.22 + +DOCUMENT(); + +loadMacros( + 'PGstandard.pl', 'PGML.pl', + 'PGtikz.pl', 'parserPopUp.pl', + 'PGstatisticsmacros.pl', 'PGcourse.pl' +); + +# generate some data is is skewed right + +do { + $n = random(5, 15); + @norm_rands = urand(5, 20, 150, 1); + @unif_rands = map { random(25, 99); } (1 .. $n); + @h = (); + for $i (0 .. 9) { + $h[$i] = scalar(grep { $_ >= 10 * $i && $_ < 10 * ($i + 1) } + (@norm_rands, @unif_rands)); + } +} until $h[0] <= 30 && $h[1] <= 30; + +$num_students = 0; +$num_students += $h[$_] for (0 .. 9); + +# generate the rectangles +$rects = ''; +for $i (0 .. 9) { + $rects .= + "\\filldraw[fill=Goldenrod] ({$i+0.5},0) rectangle ({$i+1.5},{0.35*$h[$i]});\n"; +} + +$graph = createTikZImage(); +$graph->tikzLibraries('arrows.meta'); +$graph->BEGIN_TIKZ +\tikzset{>={Stealth[scale=1.5]}} +\filldraw[ + draw=LightBlue, + fill=white, + rounded corners=10pt, + thick,use as bounding box +] (-1,-1) rectangle (11.5,11.5); +$rects; +\draw (0.5,0) rectangle (11.5,11); +\foreach \x in {10,20,...,100} \draw ({0.1*\x+0.5},0) -- ({0.1*\x+0.5},-0.1) node [scale=1.5, below] {\x}; +\foreach \y in {1,2,...,29} \draw(0.5,{0.35*\y}) -- (0.4,{0.35*\y}); +\foreach \y in {5,10,15,20,25,30} \draw (0.5,{0.35*\y}) -- (0.3,{0.35*\y}) node [scale=1.5, left] {\y}; +END_TIKZ + +$dol = random(30, 60, 10); +$num_b = 0; +$num_b += $h[$_] for (0.1 * $dol .. 9); +$ans_b = Real(100 * $num_b / $num_students); + +$dd = DropDown([ 'skewed left', 'skewed right', 'symmetric' ], 1); + +BEGIN_PGML +In a statistics class with [$num_students] students, the professor records +how much money each student has in their possession during the first class +of the semester. The histogram below is of the data collected. + +>> [! alt text !]{$graph}{400} << + +a) The number of students with less than ten dollars in their posession is +[_]{Real($h[0])} + +b) The percentage of students with more than $[$dol] in their possession is +[_]{$ans_b} + +c) The histogram is [_]{$dd} + +END_PGML + +BEGIN_PGML_SOLUTION +a) The number of students with less than ten dollars in their possession from the histogram is [$h[0]]. + +b) To determine the percentage of students with more than $[$dol] in their possession, +first use the histogram to count the number of students. This is +[```[@ join('+', @h[0.1*$dol..9]) @] = [$num_b] ```] +Then find the percentage using +[``` 100 \frac{[$num_b]}{[$num_students]} = [$ans_b] ```] + +c) The peak to the left and a long tail to the right, so this is skewed right. +END_PGML_SOLUTION + +ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_08_PictDistnsWGraphs/01Stats_08_PictDistnsWGraphs.pg b/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_08_PictDistnsWGraphs/01Stats_08_PictDistnsWGraphs.pg deleted file mode 100644 index 88c276d903..0000000000 --- a/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_08_PictDistnsWGraphs/01Stats_08_PictDistnsWGraphs.pg +++ /dev/null @@ -1,111 +0,0 @@ -## DESCRIPTION -## DBsubject(Statistics) -## DBchapter(Exploratory data analysis/descriptive statistics) -## DBsection(Graphical representations) -## Institution(The College of Idaho) -## Author(R Cruz, L Danielson, J Guild) -## Level(1) -## TitleText1('The Basic Practice of Statistics') -## AuthorText1('David Moore') -## EditionText1('5e') -## Section1('1') -## Problem1('') -## KEYWORDS('statistics', 'quantitative data', 'categorical data', 'histogram') - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - 'PGstandard.pl', 'PGML.pl', - 'parserRadioButtons.pl', 'PGtikz.pl', - 'PGcourse.pl' -); - -# Setup - -# Create a distribution to more easily answer the questions below -do { - @y = map { random(50 - 15 * $_, 60 - 15 * $_) } (0 .. 3); - $y[$_] = random(0, 1) * random(0, 3) for (4 .. 9); - $y[10] = random(1, 2); - $total = 0; - $total += $_ for @y; - $over30 = 0; - $over30 += $y[$_] for (3 .. 10); -} until ($over30 / $total > 0.08 && $over30 / $total < 0.12); - -# create the tikz code to make the bars for this. -$bars = ''; -for $i (0 .. $#y) { - $bars .= - "\filldraw[fill=LightBlue, draw = black] ({10*$i/12},0) rectangle ({(10*($i+1))/12}, {$y[$i]/7}); \n"; -} - -$graph = createTikZImage(); -$graph->tikzLibraries('arrows.meta'); -$graph->tikzOptions('yscale = 0.6'); -$graph->BEGIN_TIKZ -\tikzset{>={Stealth[scale=1.25]}} -\filldraw[ - draw=LightBlue, - fill=white, - rounded corners=10pt, - thick, use as bounding box -] (-1.25,-1) rectangle (10,10); -\foreach \y in {5,10,...,60} - \draw[lightgray] (-0.5,{\y/7}) -- ({115/12},{\y/7}); -\draw (-0.5,0) -- (9.5,0) -- (9.5,9.5)-- (-0.5, 9.5) --cycle; -\foreach \x in {0,10,...,110} - \draw({\x/12},5pt) -- ({\x/12},-5pt) node [below] {\(\x\)}; - -%\foreach \y in {1,...,20} \draw[thin, lightgray] (0,{\y/2.5}) -- (9.5,{\y/2.5}); -\foreach \y in {10,20,...,60} - \draw (-0.4,{\y/7}) -- (-0.6,{\y/7}) node[left] {\(\y\)}; -$bars - -END_TIKZ - -$rb2 = RadioButtons( - [ 'symmetric', 'skewed right', 'skewed left', 'none of the above' ], 1); - -$rb3 = RadioButtons( - [ - "above 30$PERCENT", - "between 20$PERCENT and 30$PERCENT", - "about 10$PERCENT", - "less than 3$PERCENT" - ], - 2 -); - -$showPartialCorrectAnswers = 0; - -BEGIN_PGML -In a statistics class with [$total] students, the professor records how much money -each student has in their possession during the first class of the semester. -The histogram below is of the data collected. - - -[! alt text !]{$graph}{450} - -a) The number of students with under $10 in their possession is [_]{$y[0]}{5} - -b) The histogram is - - [_]{$rb2} - -c) The percentage of students with over $30 in their possession is - - [_]{$rb3} -END_PGML - -BEGIN_PGML_SOLUTION -For this, read off the approximate bar heights to answer the questions. - -a) This needs a careful eye, but the answer is [$y[0]]. - -b) Because there is a large peak on the left and a long tail to the right, this is _skewed right_. - -c) For this, total all of the heights of the bars. The total heights of those over $30 is [$over30] and since there are [$total] students, this is about 10%. -END_PGML_SOLUTION - -ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_08_PictDistnsWGraphs/Ref_1_4.gif b/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_08_PictDistnsWGraphs/Ref_1_4.gif deleted file mode 100644 index 197e2c952b385b01ef3bf439790044bcd7653890..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3063 zcmW+#2|QKX7v7~o!&9$Guae_cGW0~l<>kpP6`3+rGM^+egglg~c4?5mnJ8{Ll;I-t zJRX@9GUUb;r!vnW8G7&j&w1MG6NMew}AYDtR>A)dG z5E2lQ5K{C29AY?=#c_ymNZ^pfA%#PlB!-w$96^L2fgp(>g&@rwBba`ifQWzu0Z9T< z1f=D_NMgd_gaW=kAL2uB2tNE}f(J(BLG3+Wsa1VSW2 z6hgEU7=dU$IGrL8K_HSq6oF`aFcQ%uak`E~1c^uzQ6!>0!ze^E$LVGY5fmaRL{SJZ z_kyNJyG<9-9@2Kv&M+=w7^4M_F%t=lBr%f0Xme;E7=duezz~c)v=WTp7|y7M;|w-| zlO#@3I4uUvo2E#!VHP3~Ng^7VxfvM2=!+A~mIOhP1W6GzIE_P(q`T=tI!E%CrU>E{ zLWoaa7CzwrchD#OMu*tK3OWtI0p^4GPXIysmo>Z8GKdNv!Oc=8bs4dhk2da6XRBq# zRsV1MVcYJy%$K!6n2O)7vstg|!zA>RP3p7a-$u$_X<(ntPH2o)_>)>DJHEeH(tbw@NcS zd!SiPY2B0c21kb41hoYAUDrK2!oArqEqOzHy`)B zKJ(+n+neXgZ@>MqzTzk{m;E+qd&+XMvJ~?|eQaOO5_p~)+_~|pr*x`-Q zwj(PB&pNPN;PY6NioVQ`GjR>l3sjWB1n;YvzLI-SY;CdoU`TY6+X&lH$bBHE zSg3eRHp@({cwDD<_u;x%<$Zrnx-A7Nz9_mQv^ZTeYQ50-RJyl>*E)WzcsA*S&W@A{tgSU3J2@VnRgbp4gVy zRjLwXPUkt5iOSxUx^*Wvv7D^fQJ=f#tyKi)>W+w5KFjy;g|F5GIP5pMOx^M=-H{M{ zQf}9UO}z;!`~@f1!=r|E=L=4)Hp=w9WJzr~5Z|mTBD>bmc(rmS$^J(BWjOyS{$PA?Xxc%=Gs0G8bDtRCoBIleLz; zrMUF4ta#qWpoc0S_i_d6bS#pBZn#*A^7B=fI~auey1a}0wM8QHT-TxCWUoFd^rnVM zn)B`6$MG^Lb!Tv)%n1K>%Y&)~aT;qkJh{0d-lMNT&D>+POwHbnF6dP?bzVOp#>A@g zo_kf#%9aP~yyB0AEog-CO@mp3D|X3o>$Mvzq+_=Im7uVvUcuEc{fRnz@c6PF$L_U+vd2)e=o^_FW8*m2DiBNX*xFpWE{CP`{Dx%&;CiZi|~n z?vU>DU(Cn$!brMn%<05r%lf!I$g2T{-pli z-{T#T+i783yV#LacH~I6jg8)DL#w^T7;)yhl%dMn_R(jPK0Y7%b)p|}udd01i3yDYhYF{9?iYVO3G zd&21yt8ov$T+6EP^u!0F3hwJP`jR6GefA|*Osq9+KW30MbVz3F^ChEk4^B~oR+@RO z^dFN}t-0Kz>94iklDfRPwTE2RInt+?-xe*DKqeY%fHUCWI}_rv}_(~_Wizdp-xSEI)t}yX4@nA$hyB$ z!@SpD)r@hj-NgE8H5P?q4baAL?6!W`fd{z`MST*s3*9%} zk++;hxRfgV>JySt%DU{#U-%sVJfbsIvN^Ct^MGF4BW_i~rS7 zHu<|EPhc_k>SOVVvJbz&wurV@4c^=B_gw7o-YS2oXRX66(XRb{Y2Q4Wy(eALcZR+_ zuF&4&E$X4aL# zTQM#d9ou?!92H!WV!p?nYwIe$%c_chKKnD=w9km2*kxcgOI^1ekMaxbK3Hp?UH&Q7 zx%^fMPe`etS!u#;a;dw-+c9(X#ITttxA&Lk?}d(=r{rH6rVIB@RSBr(RjyU!&J;;C zDk`a_rp@t8V;11nuIXRTl-@n>82eZ_``_;wL8W8X=a#y7|IQUOmrmR~H-G?8{6A8F B0iyr_ diff --git a/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch02DescribingData/02Stats_01_DescrData.pg b/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch02DescribingData/02Stats_01_DescrData.pg new file mode 100644 index 0000000000..debad1bdac --- /dev/null +++ b/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch02DescribingData/02Stats_01_DescrData.pg @@ -0,0 +1,92 @@ +## DESCRIPTION +## DBsubject(Statistics) +## DBchapter(Exploratory data analysis/descriptive statistics) +## DBsection(Description of distributions) +## Institution(The College of Idaho) +## Author(R Cruz, L Danielson, J Guild) +## Level(1) +## Static(1) +## MO(1) +## TitleText1('The Basic Practice of Statistics') +## AuthorText1('David Moore') +## EditionText1('5e') +## Section1('2') +## Problem1('') +## KEYWORDS('statistics', 'skewed', 'mean', 'median') + +# Updated by Peter Staab (Fitchburg State) on 2024.01.22 + +DOCUMENT(); # This should be the first executable line in the problem. + +loadMacros( + 'PGstandard.pl', 'PGML.pl', + 'PGtikz.pl', 'PGstatisticsmacros.pl', + 'parserPopUp.pl', 'PGcourse.pl' +); + +$s = random(0, 2); + +@norm_rands = urand(10 + 6 * ($s - 1), 3, 100, 0); +@unif_rands = map { random(6, 14) - 5 * ($s - 1) } (1 .. 25); + +@h = (); +for $i (0 .. 20) { + $h[$i] = scalar(grep { $_ == $i } (@norm_rands, @unif_rands)); +} + +# generate the rectangles +$rects = ''; +for $i (1 .. 20) { + $rects .= + "\\filldraw[fill=Goldenrod] ({$i-0.5},0) rectangle ({$i+0.5},$h[$i]);\n"; +} + +$graph = createTikZImage(); +$graph->tikzLibraries('arrows.meta'); +$graph->BEGIN_TIKZ +\tikzset{>={Stealth[scale=1.5]}} +\filldraw[ + draw=LightBlue, + fill=white, + rounded corners=10pt, + thick,use as bounding box +] (-1,-1) rectangle (21,21); +$rects; +\draw (0.5,0) rectangle (20.5,21); +\foreach \x in {5,10,15,20} \draw (\x,0) -- (\x,-0.1) node [scale=2, below] {\x}; +\foreach \y in {5,10,15,20} \draw (0.5,\y) -- (0.3,\y) node [scale=2, left] {\y}; +END_TIKZ + +$skew = DropDown([ 'right', 'symmetric', 'left' ], $s); +$middle = DropDown([ 'mean', 'about equal', 'median' ], $s); + + +BEGIN_PGML +Consider the histogram shown below. + +[! alttest !]{$graph}{400} + +a) Is this data skewed to the right, close to symmetric, or skewed to the left? [_]{$skew} + +b) Which is bigger for this data set, the mean or the median, or are they about equal? [_]{$middle} + +END_PGML + +if ($s==0) { +BEGIN_PGML_SOLUTION +In this case, since there is a peak to the left and a tail on the right, this is skewed +to the right. The mean is closer to the peak and the median (middle of the data) is to the right of the mean, so the median is larger. +END_PGML_SOLUTION +} elsif ($s ==1) { +BEGIN_PGML_SOLUTION +In this case, the histogram appears relatively symmetric (though not perfect). +Because it is symmetric, the mean and median is about equal. +END_PGML_SOLUTION +} else { +BEGIN_PGML_SOLUTION +In this case, since there is a peak to the right and a tail on the left, this is skewed +to the left. The mean is closer to the peak and the median (middle of the data) is to the left of the mean, so the mean is larger. +END_PGML_SOLUTION + +} +ENDDOCUMENT(); diff --git a/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch02DescribingData/02Stats_01_DescrData/02Stats_01_DescrData.pg b/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch02DescribingData/02Stats_01_DescrData/02Stats_01_DescrData.pg deleted file mode 100644 index 61060a1148..0000000000 --- a/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch02DescribingData/02Stats_01_DescrData/02Stats_01_DescrData.pg +++ /dev/null @@ -1,88 +0,0 @@ -## DESCRIPTION -## DBsubject(Statistics) -## DBchapter(Exploratory data analysis/descriptive statistics) -## DBsection(Description of distributions) -## Institution(The College of Idaho) -## Author(R Cruz, L Danielson, J Guild) -## Level(1) -## Static(1) -## MO(1) -## TitleText1('The Basic Practice of Statistics') -## AuthorText1('David Moore') -## EditionText1('5e') -## Section1('2') -## Problem1('') -## KEYWORDS('statistics', 'skewed', 'mean', 'median') - -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGstandard.pl", - "MathObjects.pl", - "PGcourse.pl" -); - -TEXT(beginproblem()); - -###################################### -# Setup - -@pic= ("3-413210.gif", "3-118225.gif"); -@ANSWER1=("SKEWED RIGHT", "SKEWED LEFT"); -@ANSWER2=("MEAN", "MEDIAN"); -$choose = random(0,1,1); - -###################################### -# Main text - -BEGIN_TEXT -Consider the histogram shown below. -$BR -$BCENTER -\{ image($pic[$choose], height=>300, width=>400, tex_size => 600) \} -$ECENTER - -$PAR -(a) Is this data skewed to the right, symmetric, or skewed to the left? \{ ans_rule(20)\} -$BR -(Enter "SKEWED RIGHT", "SYMMETRIC", or "SKEWED LEFT" without the quotations.) - -$PAR -(b) Which is bigger for this data set, the mean or the median, or are they about equal? \{ ans_rule(20)\} -$BR -(Enter "MEAN", "MEDIAN" or "ABOUT EQUAL" without the quotations.) - -END_TEXT - -###################################### -# Answers - -$showPartialCorrectAnswers = 1; - -Context()->strings->add("mean"=>{},"median"=>{},"about equal"=>{}, - "skewed left"=>{},"skewed right"=>{},"symmetric"=>{}); - -$ans_a = String($ANSWER1[$choose]); -ANS($ans_a->cmp); - -$ans_b = String($ANSWER2[$choose]); -ANS($ans_b->cmp); - -ENDDOCUMENT(); # This should be the last executable line in the problem. - - - - - - - - - - - - - - - - - diff --git a/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch02DescribingData/02Stats_01_DescrData/3-118225.gif b/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch02DescribingData/02Stats_01_DescrData/3-118225.gif deleted file mode 100644 index d85ee1df5504619cdf5271878520d884752fcea2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4521 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 UK(0Q}q(0cIKGchyg$0oNAO9@NlmGw# diff --git a/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch02DescribingData/02Stats_01_DescrData/3-413210.gif b/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch02DescribingData/02Stats_01_DescrData/3-413210.gif deleted file mode 100644 index 45e3479d74e27ca81e099b405ae9857570b5a069..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4651 zcmW+&2{=^y8$SKpl)BwgwziS(wO)n9&~l`#l~6ILdlDK;Wh)G3j&%lEvhR*y497wM0s?>t03iU300;u02!J5~fC2;*08s!! z0T=}k6hKh`LjeE-2p9lj0E7WB1|S%KVgQB#000sM>wu5|1VjX_AO?W=mIML_53<7bI1XxfC!5|ES z2n?byh`}JvoPY@WAq0dG5J5l`0Wk!`vl;u;Y!5J!SA5XL|R z15pgbFc1)^i;sgLfjlrGAPr*xjH^Z<2(Tdn3=?340HXvLBfx-wjbI^2unvxlgW&UE zTwekt*b;(Z7=jT9Mj;r3@R4{oUWn%efxs{d!x#+XP7n|n=L6v>1V#`TMPLkpaeD|T zjFW`$Iuu4w7)4laa7>qNA@Ma7~Fc`&P41)o|y};?=ZsSF`hqzt1GXfV01c4S1 zK`;>^peO;w2)H@84+4Q8PymAn;Dx0Gf*r~fH!n5JKr{W4r!)p4MuET=h&pc8h$ zfScPID{IEGZsq2+Cmz4umS#}S>`2vcpBiW_&wrB%25vuSSW)mUM?Y5nMq5SUhx{u! zhUtcttS+`ix#M74CA)_MJr6r*R8`bhPX55U(Oy;D&vO}WOSjqs57v3jPYt&7IG>)v z8-)*DtS%jT&JaPb?S|LHSIg1k*>V2!wvo)j;=*{JB_yF_=H4~komBtJf~xq z2FF|mUe?|J-{JN3>%Oo0yPqi>xY*!#XI}N`uB)#PP265wdax@#bIs;q#^R_9;lf1K^3z zfk$FwZ@Z@?FOkBJHHZ&ClIBlzMplg$Q(lzRREnpH$zHMkeX5y@r#7tRz(KqILU(zn$-AtmoGXKYH6Nxoi9Jl%v;+epI$qwDOP-Xv%-50b&rCgW!tQ6kwdl0@)vG- z_kyKU#ktEy|5$ZQMhm(MKtxR}W; z4kT9kDe|v859ircQFIhMxU`KoJ$=pTBn^&s>eSEA9-IG&;fwtI%^8WV3nEtg%1|f9 zlJ9tFy!52s{5U~QxJR)<`ul69*qp8v-M9~9#7E`L87HTXlc;X9wTIj5(n`0|MCXQf zDwTZW?&2)Z6sT}SzpvG=RsZ;Ma#rC-sZFLIxtn&eesRTtcK6#z&e*BUiTtl!OTEEg zResHiRIf$M^l-la4!+5Gx-zC^zP3i+w{q<=RZW@zJj*}jD>tXGzNO;E#={Hf;y2?v z1M{TKHG7_gNV$;rk6@e4K5OL#yU;dx^Z>>}@qe7#WE)A65~iJK6g#OKqI%wR=V8;v z<3q>k*8B`tx7a6!t{i&UMw@H7%&g_T-^}!0K{Ig{iI#<1wYMI#qn0BioeF z_>}W}Ir^51cbe$#)wgVvorq_h8rKaX8~f~9naM?tlyXlu#dq(amRI*O<{v#jFrvwm z!+%T4&9GNvr&{Hd+&|8%QeU-KE`=VWt(n~^+B*R{kc>SKU46X6mMjys{Pvo>`~887 z(1l_z6SCdjp#3}dYuuVt3OMr$ks7?Abc|#gnjMoZxAU^5%!N0hd{yR;lu4@N%KOyM zom!eRdyNaXeaOt%nyRHH*L214s%A-C?r&4a&fe}Mre^#@KVsrl`uS^37W*Q!DlD{o zrrvTAj%9mS6k4h|c9)N-I(_*?CWiC7LpH~$d_ItG6w1F+)x9sa#=|bGqPC}IVP7t7 zv*Puw3cU%;_@d|w&Nee*#=RpyBZYL-zF7XHMdGi&>g28}I-eb_ee&8=l&aWzBZI&InqP)o)Z;FNbZ}!(N z)P1WT_B~iPFt5~AyKL8G=S{qkcdaLX`Q@xxbKT&|!^MW?OLO;MXj!rMi92moVh5@A zy=ztOsZSepIVhrQJx@_@JQ8XD6VT}wUVZ!2#HcL5WHnJVaq+2)F6WWnjusa#?1j4H?ASdGCRC1Jy3vSl)1Ee7fU33q@t&R-`GQA)1&!}s(cU(H* zJMG)k^j*Ef^tC&q|A56?8;SRngdf>;)_p@T@$TV|-*YcGk2W1zZd2dlk$d|TSttBm zXXZ_2lHar%r@O1Q@PS>CvLtz`o1#opQ#CrgbBeTD+hZYImHNqfzZgyFdGdml)y%8t zqZ~>{&ssWnIJxucZ7u$%j~-@5gEJaVmYsyAujav*%mYm0hu;i<2sA4%9T-G_Vfi&HH^nen6_3ytM|&Ps=) z>OS{fERYVhy&LQ~Fw)wf)^gjRc{=*no1x3R2IZ>t8FSSIR+KLhy|wwS@7I2oo@6#+ zy>|Y5`>$uRnO-jDRQJ-zq%#41L?(smk-~m5(R5^ml3nsGcGddz=X+jW7GJte`B$bI zc2vJOYd$|7U9Ta1Y^9z}y_ZX`$NVaC*q8c#dU1aDZEBYLG_qU}L#v;K%+=o>yg75F zKYjN7O$uFPyDPeWnqqD~J8&m*>9t@bBGd2{A~G4Z9-*V_L1fyMlUjA>iaW!K16+QH6i%= zc;H4anzWGjih5AYVqj3SxRy|0z}Um8gfoXG$es^%w0mKNlfffq!8f?nuB{;_$^LWA zl;q*yF{uz^Mi9SA)n155ChMF_a=GFaG~OX}Ix z@Z;(b&k5}aFI9Gue{oW<`cf!QTx-3&#VBtnzDLE`7DfGF9 z`pbgL%@+Qr$bR``M#sd-H?qd>7(O3bs9lV3Te4H zDJD@oR-yIr-cT*IzNjy~G)=jHi2{a4(xcj*U=3n~wp`r*Y93$HP&BBC9gvMTYmK|q z_jpYxPQ)R;p(Xyke*C7%(-JlD2Iom}H%ak#B%<^ShOlthSa zXrhh;99bSCdH$TcL~?4fS6W~4{lch!yw9jvBwrAUglgjQz2iMdiOl54%*nWt$veLa z;_{MHDjX7{y;C!4PRDIaN^pouBBlN-m&VfZ*LK@J&H+Y}lmjN>dD-|?6|Q%SEv z6Sjxt%2N14?4GL2mN4ykjF5g8tTio|kD)VUkmr zjs^cd{)T{ zt5lNBU3qwJMY5d2u1;as*0S%(@Bi2%pZ1MS7L_$78hM))Nzi3lQi|a6qR0IGjhaQz zKNnqP6@Abyrc;XE?JiCfCHBhS(EVPFv5KF`mkj8ZOz?{eYfHZHOJ-L}<|H}aH90>l zISUldlBC>PlV&`N^{;(N$_r?~gk2O{qUtx>K zihsa9=>Rs5YE|O9-!0I{_o7wxLbpd8FS3jVzcf$ri>;I(cH&g%s diff --git a/OpenProblemLibrary/Rochester/setProbability7RandomVariables/p1.pg b/OpenProblemLibrary/Rochester/setProbability7RandomVariables/p1.pg index 7389954fea..064236ea29 100644 --- a/OpenProblemLibrary/Rochester/setProbability7RandomVariables/p1.pg +++ b/OpenProblemLibrary/Rochester/setProbability7RandomVariables/p1.pg @@ -10,58 +10,87 @@ ## Level(1) ## KEYWORDS('Random Variable', 'Probability Density Function', 'PDF', 'Probability Distribution') +# updated by Peter Staab (Fitchburg State University) on 2024.01.25 -DOCUMENT(); # This should be the first executable line in the problem. +DOCUMENT(); # This should be the first executable line in the problem. loadMacros( - "PGstandard.pl", - "PGchoicemacros.pl", - "PGgraphmacros.pl", - "PGcourse.pl" + 'PGstandard.pl', 'PGML.pl', 'niceTables.pl', 'parserPopUp.pl', + 'PGcourse.pl' ); -TEXT(beginproblem()); $showPartialCorrectAnswers = 0; +@b1 = (random(0, .3, .1), random(.1, .3, .1), random(.1, .3, .1)); +$b1[3] = 1 - $b1[0] - $b1[1] - $b1[2]; + +@b2 = (random(0, .3, .1), random(.1, .3, .1), random(-0.3, -0.1, .1)); +$b2[3] = 1 - $b1 - $b2 - $b3; +@b2 = random_subset(4, @b2); + +do { + @b3 = map { random(0, 0.3, 0.1) } (1 .. 4); + $sum = 0; + $sum += $_ for (@b3); +} until $sum != 1; + +@tables = ( + DataTable( + [ + [ 'Event', '\(e_1\)', '\(e_2\)', '\(e_3\)', '\(e_4\)' ], + [ 'Probability', @b1 ], + ], + align => '|c|r|r|r|r|', + horizontalrules => 1 + ), + DataTable( + [ + [ 'Event', '\(e_1\)', '\(e_2\)', '\(e_3\)', '\(e_4\)' ], + [ 'Probability', @b2 ], + ], + align => '|c|r|r|r|r|', + horizontalrules => 1 + ), + DataTable( + [ + [ 'Event', '\(e_1\)', '\(e_2\)', '\(e_3\)', '\(e_4\)' ], + [ 'Probability', @b3 ], + ], + align => '|c|r|r|r|r|', + horizontalrules => 1 + ) +); + +@dropdowns = ( + DropDown([ 'Valid', 'Invalid' ], 0), + DropDown([ 'Valid', 'Invalid' ], 1), + DropDown([ 'Valid', 'Invalid' ], 1) +); + +@opts = random_subset(3,0..2); + +BEGIN_PGML +Determine whether the following are valid probability models or not. Determine if each is a valid or invalid probability model. + +a) Table 1 -$b[0] = random(0,.3,.1); -$b[1] = random(.1,.3,.1); -$b[2] = random(.1,.3,.1); -$b[3] = 1-$b[0]-$b[1]-$b[2]; + [$tables[$opts[0]]]* -$b1 = random(0,.3,.1); -$b2 = random(.1,.3,.1); -$b3 = random(-.3,-.1,.1); -$b4 = 1-$b1-$b2-$b3; + Answer: [_]{$dropdowns[$opts[0]]} -$a = random(2,5,1); +b) Table 2 + [$tables[$opts[1]]]* -@second_row = ($b[0], $b[1], $b[2], $b[3]); -@slice = NchooseK(4,4); -@ssecond_row = @second_row[@slice]; -BEGIN_TEXT -Determine whether the following are valid probability models or not. Type "VALID" if it is -valid, or type "INVALID" if it is not. $PAR -(a) $PAR -\{begintable(5)\} -\{row("Event", "\( e_1\)", "\( e_2\)", "\(e_3\)", "\( e_4\)")\} -\{row(" Probability", "\($ssecond_row[0]\)", "\($ssecond_row[1]\)", "\($ssecond_row[2]\)", "\($ssecond_row[3]\)" )\} -\{endtable()\} + Answer: [_]{$dropdowns[$opts[1]]} -Answer: \{ans_rule(10)\}$PAR +c) Table 3 -(b) $PAR -\{begintable(5)\} -\{row("Event", "\( e_1\)", "\( e_2\)", "\( e_3\)", "\( e_4\)")\} -\{row(" Probability ", "\($b1\)", "\($b2\)", "\($b3\)", "\($b4\)" )\} -\{endtable()\} + [$tables[$opts[2]]]* -Answer: \{ans_rule(10)\} + Answer: [_]{$dropdowns[$opts[2]]} -END_TEXT -ANS(str_cmp("VALID")); -ANS(str_cmp("INVALID")); -ENDDOCUMENT(); # This should be the last executable line in the problem. +END_PGML +ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/OpenProblemLibrary/Rochester/setProbability7RandomVariables/ur_pb_7_3.pg b/OpenProblemLibrary/Rochester/setProbability7RandomVariables/ur_pb_7_3.pg index fcffc54d1c..7f2e36992a 100644 --- a/OpenProblemLibrary/Rochester/setProbability7RandomVariables/ur_pb_7_3.pg +++ b/OpenProblemLibrary/Rochester/setProbability7RandomVariables/ur_pb_7_3.pg @@ -11,63 +11,63 @@ ## Level(2) ## KEYWORDS('Random Variable', 'Discrete', 'Probability Density Function', 'PDF', 'Probability Distribution') -DOCUMENT(); # This should be the first executable line in the problem. +# updated by Peter Staab (Fitchburg State) on 2024.01.25 -loadMacros( - "PGstandard.pl", - "PGchoicemacros.pl", - "PGcourse.pl" +DOCUMENT(); + +loadMacros('PGstandard.pl', 'PGML.pl', 'niceTables.pl', 'PGcourse.pl'); + +$a1 = random(1, 20); +@a = ('X', $a1 .. $a1 + 4); + +do { + @p = ('P(X)', map { random(.1, .3, .1) } (1 .. 3), 0.1); + $p[5] = 1 - $p[1] - $p[2] - $p[3] - $p[4]; +} until $p[2] != $p[3]; +# warn pretty_print(~~@p); + +@event = ( + "P(x=$a[3])", + "P(x>$a[3])", + "P(x\ge $a[2])", + "P(x\le $a[4])", + "P(x\ge $a[4] \mbox{ or } x<$a[2])", + "P(x<$a[5])", + "P(x=$a[1])", + "P($a[1]\le x <$a[3])" ); -TEXT(beginproblem()); -$showPartialCorrectAnswers = 1; - -$a1 = random(1,20,1); -$a2 = $a1+1; -$a3 = $a2+1; -$a4 = $a3+1; -$a5 = $a4+1; - -$p1 = random(.1,.3,.1); -$p2 = random(.1,.2,.1); -$p3 = random(.1,.2,.1); -while($p2==$p3) {$p3 = random(.1,.2,.1);} -$p4 = .1; -$p5 = 1-$p1-$p2-$p3-$p4; - -@event = ("\(P(x=$a3)\)", - "\(P(x>$a2)\)", - "\(P(x\ge $a2)\)", - "\(P(x\le $a4)\)", - "\(P(x\ge $a4 \mbox{ or } x<$a2)\)", - "\(P(x<$a5)\)", - "\(P(x=$a1)\)", - "\(P($a1\le x <$a3)\)"); - -@ans = ($p3, ($p3+$p4+$p5), ($p2+$p3+$p4+$p5), ($p1+$p2+$p3+$p4), - ($p4+$p5+$p1), ($p1+$p2+$p3+$p4), $p1, -($p1+$p2)); - -@slice = NchooseK(8,3); -@sevent = @event[@slice]; -@sans = @ans[@slice]; - -BEGIN_TEXT -\{begintable(6)\} -\{row("\(x\)", "\($a1\)", "\($a2\)", "\($a3\)", "\($a4\)", "\($a5\)")\} -\{row("\(P(x)\)", "\($p1\)", "\($p2\)", "\($p3\)", "\($p4\)", "\($p5\)")\} -\{endtable()\} -Given the discrete probability distribution above, determine the following: $PAR -(a) $SPACE $sevent[0] \(=\) \{ans_rule(10)\} $PAR -(b) $SPACE $sevent[1] \(=\) \{ans_rule(10)\} $PAR -(c) $SPACE $sevent[2] \(=\) \{ans_rule(10)\} - - -END_TEXT - -ANS(num_cmp($sans[0])); -ANS(num_cmp($sans[1])); -ANS(num_cmp($sans[2])); - - -ENDDOCUMENT(); # This should be the last executable line in the problem. +@ans = ( + $p[3], + $p[4] + $p[5], + 1 - $p[1], + 1 - $p[5], + $p[1] + $p[4] + $p[5], + 1 - $p[5], + $p[1], + $p[1] + $p[2] +); + +@slice = random_subset(3, 0 .. $#event); + +$tab = DataTable( + [ [@a], [@p] ], + align => '|c|r|r|r|r|r|', + horizontalrules => 1 +); + +BEGIN_PGML +Given the discrete probability distribution: +[$tab]* + +determine the following: + +a) [`[$event[$slice[0]]] =`] [_]{$ans[$slice[0]]} + +b) [`[$event[$slice[1]]] =`] [_]{$ans[$slice[1]]} + +c) [`[$event[$slice[2]]] =`] [_]{$ans[$slice[2]]} + +END_PGML + +ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/OpenProblemLibrary/Rochester/setStatistics2Measures/ur_stt_2_4.pg b/OpenProblemLibrary/Rochester/setStatistics2Measures/ur_stt_2_4.pg index 8f9a34b598..dd547b0cf8 100644 --- a/OpenProblemLibrary/Rochester/setStatistics2Measures/ur_stt_2_4.pg +++ b/OpenProblemLibrary/Rochester/setStatistics2Measures/ur_stt_2_4.pg @@ -16,67 +16,55 @@ ## Problem1('7') ## KEYWORDS('Measure', 'Mean', 'Median', 'Skew','statistics','measures','mean','median') -DOCUMENT(); # This should be the first executable line in the problem. - -loadMacros( - "PGstandard.pl", - "PGchoicemacros.pl", - "PGgraphmacros.pl", - "PGcourse.pl" -); - -TEXT(beginproblem()); -$showPartialCorrectAnswers = 1; - -$median = random(70,85,1); -$a6 = $median; -$b5 = $a6-3; -$a5 = random($b5,$a6,1); -$b4 = $b5-5; -$a4 = random($b4,$b5,1); -$b3 = $b4-10; -$a3 = random($b3,$b4,1); -$b2 = $b3-15; -$a2 = random($b2,$b3,1); -$b1 = $b2-20; -$a1 = random($b1,$b2,1); -$a7 = $a6+1; -$c8 = $a7+2; -$a8 = random($a7,$c8,1); -$c9 = $c8+3; -$a9 = random($a8,$c9,1); -$c10 = $c9+4; -$a10 = random($a9,$c10,1); -$a11 = random($a10,100,1); - -$mean = ($a1+$a2+$a3+$a4+$a5+$a6+$a7+$a8+$a9+$a10+$a11)/11; - -$median11 = $median * 11; -$mean11 = ($a1+$a2+$a3+$a4+$a5+$a6+$a7+$a8+$a9+$a10+$a11); - -if ($mean11 > $median11) { $ans='SR';} -if ($mean11 < $median11) { $ans='SL';} -if ($mean11 == $median11) { $ans='SYM';} - -BEGIN_TEXT +# Updated by Peter Staab (Fitchburg State) on 2024.01.22 +DOCUMENT(); + +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); + +# Pick the median. +$median = random(70, 85, 1); + +# Total number of points will be 2n+1 and add n points above and below the median. +$n = random(4, 6); +@pts = ($median); +for (1..4) { + push(@pts, random($median - 10, $median), random($median, $median+10)); +} +@pts = random_subset(scalar(@pts), @pts); + +$sum = 0; +$sum += $_ for (@pts); +$mean = Real($sum / scalar(@pts)); + +$sym = $mean > $median ? 0 : $mean < $median ? 1 : 2; +$dd = DropDown([ 'skewed left', 'skewed right', 'symmetric' ], $sym); + +BEGIN_PGML Calculate the mean and median of the following grades on a math test: -\[ $a11, \ $a10, \ $a9, \ $a8, \ $a7, \ $a6, \ $a5, \ $a4, \ $a3, \ $a2, \ $a1 \] +[``` [@ join(', ', @pts) @] ```] + +a) Mean = [_]{$mean} + +b) Median = [_]{Real($median)} -Mean = \{ans_rule(10)\} $BR +c) Is this data set skewed to the right, symmetric, or skewed to the left? [_]{$dd} -Median = \{ans_rule(10)\} $BR +END_PGML -Is this data set skewed to the right, symmetric, or skewed to the left? $BR -(Enter SR, SYM, or SL); +BEGIN_PGML_SOLUTION +a) The mean is found by sum of the value over the number of values or +[``` \text{mean}= \frac{[$sum]}{[@ 2*$n+1 @]} = [$mean] ```] -\{ans_rule(10)\} +b) The median is the middle value. We can order the data to get -END_TEXT +[``` [@ join(', ', num_sort(@pts)) @] ```] +and this shows the middle value is [$median] -ANS(num_cmp($mean)); -ANS(num_cmp($median)); -ANS(str_cmp($ans)); +c) Since the mean is [@ $sym == 0 ? 'greater' : $sym == 1 ? 'smaller' : 'equal' @] to +the median the data is +[@ $sym == 0 ? 'skewed left' : $sym == 1 ? 'skewed right' : 'symmetric' @]. +END_PGML_SOLUTION -ENDDOCUMENT(); # This should be the last executable line in the problem. +ENDDOCUMENT(); # This should be the last executable line in the problem. From 238b60466faf50c846a3975a59c792a64ddec0c1 Mon Sep 17 00:00:00 2001 From: Peter Staab Date: Thu, 26 Jun 2025 07:20:44 -0400 Subject: [PATCH 2/2] More solutions and reformatting of problems. --- .../Algebra/intervals/graphing-intervals.pg | 28 ++-- .../Probability/contingency_table.pg | 78 ++++++++---- Contrib/Fitchburg/Probability/cookies.pg | 25 +++- Contrib/Fitchburg/Probability/discrete_pdf.pg | 15 +-- Contrib/Fitchburg/Probability/ice-cream.pg | 57 +++++++-- Contrib/Fitchburg/Probability/living.pg | 36 ++++-- .../Fitchburg/Probability/prob-cards-01.pg | 24 +++- .../Fitchburg/Probability/prob-cards-02.pg | 17 ++- .../Fitchburg/Probability/proportions-pets.pg | 22 +++- .../Probability/siblings_rel_freq.pg | 10 +- Contrib/Fitchburg/Probability/tree-diagram.pg | 43 ++++++- .../Statistics/Basics/basic-definitions.pg | 120 ++++++++---------- .../Basics/definition-population.pg | 1 + .../ConfidenceIntervals/8_3_1_RMN.pg | 11 +- .../ConfidenceIntervals/8_3_2_RMN.pg | 16 ++- .../Statistics/Descriptive/line-graph.pg | 53 +++++--- .../Statistics/Descriptive/quantiles.pg | 54 +++++--- .../Statistics/Descriptive/stem-leaf.pg | 57 +++++---- .../Statistics/Distributions/6_2_RMN.pg | 55 ++++++-- .../Statistics/Distributions/6_4_RMN.pg | 31 ++++- .../Distributions/applied-normal.pg | 13 ++ .../Statistics/Distributions/normal-01.pg | 14 ++ .../Statistics/Distributions/pz_2_RMN.pg | 10 ++ .../41IntAlg_04_LinearIneq.pg | 37 ++++-- .../41IntAlg_05_LinearIneq.pg | 9 +- .../01Stats_07_pictDistnsWGraphs.pg | 61 +++++---- .../01Stats_08_PictDistnsWGraphs.pg | 3 - .../02Stats_01_DescrData.pg | 9 +- .../setProbability7RandomVariables/p1.pg | 60 ++++----- .../ur_pb_7_3.pg | 48 +++++-- .../setStatistics2Measures/ur_stt_2_4.pg | 10 +- 31 files changed, 684 insertions(+), 343 deletions(-) diff --git a/Contrib/Fitchburg/Algebra/intervals/graphing-intervals.pg b/Contrib/Fitchburg/Algebra/intervals/graphing-intervals.pg index e2cb9cf267..6cfbc97606 100644 --- a/Contrib/Fitchburg/Algebra/intervals/graphing-intervals.pg +++ b/Contrib/Fitchburg/Algebra/intervals/graphing-intervals.pg @@ -17,8 +17,7 @@ loadMacros('PGstandard.pl', 'PGML.pl', 'parserGraphTool.pl', 'PGcourse.pl'); $x1 = random(1, 5); $gt1 = GraphTool("{interval, (-$x1,$x1]}")->with( - availableTools => - [ 'IntervalTool', 'IncludeExcludePointTool' ], + availableTools => [ 'IntervalTool', 'IncludeExcludePointTool' ], numberLine => 1, bBox => [ -6, 6 ], ticksDistanceX => 1, @@ -29,8 +28,7 @@ $gt1 = GraphTool("{interval, (-$x1,$x1]}")->with( $x2 = random(-5, 5); $gt2 = GraphTool("{interval, (-inf,$x2)}")->with( - availableTools => - ['IntervalTool', 'IncludeExcludePointTool' ], + availableTools => [ 'IntervalTool', 'IncludeExcludePointTool' ], numberLine => 1, bBox => [ -6, 6 ], ticksDistanceX => 1, @@ -39,13 +37,25 @@ $gt2 = GraphTool("{interval, (-inf,$x2)}")->with( ); BEGIN_PGML -Graph the solution set for the interval [`(-[$x1],[$x1]]`]. +a) Graph the solution set for the interval [`(-[$x1],[$x1]]`]. -[_]{$gt1} + [_]{$gt1} -Graph the solution set for the linear inequality [`x < [$x2]`]. +b) Graph the solution set for the linear inequality [`x < [$x2]`]. -[_]{$gt2} + [_]{$gt2} END_PGML -ENDDOCUMENT(); \ No newline at end of file +BEGIN_PGML_SOLUTION +a) Note that the left endpoint is open and the right one is closed. Thus +graph an open endpoints on the left and a closed one on the left. + +[$gt1->generateAnswerGraph]* + +b) This is the set of all points strictly less than [$x2], so the left endpoint +should go to infinite and right one is open at [$x2]. + +[$gt2->generateAnswerGraph]* +END_PGML_SOLUTION + +ENDDOCUMENT(); diff --git a/Contrib/Fitchburg/Probability/contingency_table.pg b/Contrib/Fitchburg/Probability/contingency_table.pg index 4ef85d6705..4ea4fb6a7e 100644 --- a/Contrib/Fitchburg/Probability/contingency_table.pg +++ b/Contrib/Fitchburg/Probability/contingency_table.pg @@ -1,48 +1,52 @@ ## DESCRIPTION ## Filling in a contingency table and answering probability questions based on it. -## ## ENDDESCRIPTION ## DBsubject(Probability) ## DBchapter(Sample Space) ## DBsection(Probability: direct computation, inclusion/exclusion) +## KEYWORDS('contingency table','TV') ## Institution(Fitchburg State University) ## Author(Peter Staab) ## Level(1) DOCUMENT(); -loadMacros('PGstandard.pl', 'PGML.pl', 'niceTables.pl', 'contextPercent.pl', 'PGcourse.pl'); +loadMacros( + 'PGstandard.pl', 'PGML.pl', + 'niceTables.pl', 'contextPercent.pl', + 'PGcourse.pl' +); Context('Percent'); do { - $stream = random(35,65,5); + $stream = random(35, 65, 5); - $ssports = random(10,25); - $stv = random(5,15); - $smovie = random(10,20); - $sother = $stream - $ssports - $stv -$smovie; + $ssports = random(10, 25); + $stv = random(5, 15); + $smovie = random(10, 20); + $sother = $stream - $ssports - $stv - $smovie; } until $sother > 5; -$not_stream = 100 - $stream; +$not_stream = 100 - $stream; do { - $nsports = random(10,20); - $ntv = random(5,15); - $nmovie = random(10,20); - $nother = $not_stream- $nsports - $ntv -$nmovie; - } until $nother > 3; - - -$tab = DataTable([ - [ '', 'Sports', 'TV series', 'movies', 'other', 'total'], - [ 'Stream', $ssports, PGML('[_]{$stv}'), $smovie, $sother, $stream], - [ "Don't Stream", $nsports, $ntv, PGML('[_]{$nmovie}'), PGML('[_]{$nother}'), PGML('[_]{$not_stream}')], - ['Total', PGML('[_]{Real($ssports+$nsports)}'), PGML('[_]{Real($stv+$ntv)}'), $smovie+$nmovie, PGML('[_]{$nother+$sother}'), 100] - ], horizontalrules => 1, align => '|r|r|r|r|r|r|' - ); + $nsports = random(10, 20); + $ntv = random(5, 15); + $nmovie = random(10, 20); + $nother = $not_stream - $nsports - $ntv - $nmovie; +} until $nother > 3; + BEGIN_PGML One-hundred (100) people were surveyed about their video watching. They were asked about whether they stream or not and their primary watching preference. The following incomplete table was found: -[$tab]* +[# + [. .] [. Sports .] [. TV series .] [. movies .] [. other .] [. Total .]* + [. Stream .] [. [$ssports] .] [. [_]{$stv} .] [. [$smovie] .] [. [$sother] .] + [. [$stream] .]* + [. Don't Stream .] [. [$nsports] .] [. [$ntv] .] [. [_]{$nmovie} .] + [. [_]{$nother} .][. [_]{$not_stream} .]* + [. Total .] [. [_]{Real($ssports+$nsports)} .] [. [_]{Real($stv+$ntv)} .] + [. [$smovie + $nmovie].] [. [_]{Real($nother+$sother)}.] [. 100 .] +#]{ horizontalrules => 1, padding => [0.25, 0.25]} Complete the above table. @@ -55,4 +59,32 @@ c) [` P(S\text{ or } M) = `] [_]{Real(($stream + $nmovie)/100)} END_PGML +BEGIN_PGML_SOLUTION +The table needs to be constructed such that all values are filled in and consistent. For example, the total sports are the sum of the above two values or [$ssports+$nsports]. The number of people who preference is to stream movies can be found by [`[$stream] - [$ssports] - [$smovie] - [$sother] = [$stv] `]. Continuing +this, the table can be constructed as + +[# + [. .] [. Sports .] [. TV series .] [. movies .] [. other .] [. Total .]* + [. Stream .] [. [$ssports] .] [. [$stv] .] [. [$smovie] .] [. [$sother] .] + [. [$stream] .]* + [. Don't Stream .] [. [$nsports] .] [. [$ntv] .] [. [$nmovie] .] + [. [$nother] .][. [$not_stream] .]* + [. Total .] [. [$ssports+$nsports] .] [. [$stv+$ntv] .] + [. [$smovie + $nmovie].] [. [$nother+$sother].] [. 100 .] +#]{ horizontalrules => 1, padding => [0.25, 0.25]} + +Next, the events are found by taking the total number of people in a category and dividing by the total (or 100). + +a) This is the sports preference, so take the total sports over 100 or +[@ ($ssports+$nsports)/100 @] + +b) This is the probability that a person perfers to stream sports or [$ssports/100]. + +c) This is the probability that a person prefers streaming or movies. The total number of this is +[` [$stream] + [$nmovie+$smovie] - [$smovie] = [$stream + $nmovie]`], +where the number who prefer streaming movies is double counted in the total. +Therefore the probability is [@($stream+$nmovie)/100@] + +END_PGML_SOLUTION + ENDDOCUMENT(); diff --git a/Contrib/Fitchburg/Probability/cookies.pg b/Contrib/Fitchburg/Probability/cookies.pg index a53493e8ba..e72b60e088 100644 --- a/Contrib/Fitchburg/Probability/cookies.pg +++ b/Contrib/Fitchburg/Probability/cookies.pg @@ -24,25 +24,36 @@ loadMacros( Context("Percent"); -$cookies = random(32, 46); -$nuts = random(10, 16); -$both = random(2, 8); +$chocolate = random(32, 46); +$nuts = random(10, 16); +$both = random(2, 8); $p = randomPerson(); -$allergic = ($cookies + $nuts - $both) / 100; +$allergic = ($chocolate + $nuts - $both) / 100; $safe = 1 - $allergic; BEGIN_PGML -In a box of assorted cookies, [$cookies]% contain chocolate, [$nuts]% +In a box of assorted cookies, [$chocolate]% contain chocolate, [$nuts]% contain nuts, and [$both]% contain both chocolate and nuts. [$p] is allergic to both chocolate and nuts. a) What is the probability that a cookie contains chocolate or nuts - (they can't eat it)? [___________]{Percent($allergic)} + ([$p->they] can't eat it)? [___________]{Percent($allergic)} b) What is the probability that a cookie does not contain chocolate or nuts - (they can eat it)? [___________]{Percent($safe)} + ([$p->they] can eat it)? [___________]{Percent($safe)} END_PGML +BEGIN_PGML_SOLUTION +Without loss of generalization, we can assume that there are 100 cookies in the box. +Then there are [$chocolate] chocolate cookies, [$nuts] cookies with nuts and [$both] contain both. The rest are safe to eat. + +The total number of cookies that [$p] is allergic to is [` [$chocoloate] + [$nuts] - [$both] = [$chocolate+$nuts-$both] `] where the number of cookies with both is +double counted. + +a) There are [@ Percent($allergic) @] that [$p->they] are allergic to. +b) There are [@ Percent($safe) @] that are safe for [$p] to eat. +END_PGML_SOLUTION + ENDDOCUMENT(); diff --git a/Contrib/Fitchburg/Probability/discrete_pdf.pg b/Contrib/Fitchburg/Probability/discrete_pdf.pg index 57a1c45522..96609ab423 100644 --- a/Contrib/Fitchburg/Probability/discrete_pdf.pg +++ b/Contrib/Fitchburg/Probability/discrete_pdf.pg @@ -4,15 +4,10 @@ # Modified for WeBWorK by Michael Stassen mstassen(at)fitchburgstate(dot)edu # ENDDESCRIPTION -## DBsubject('Introductory Statistics') -## DBchapter('1') -## DBsection('2') -## KEYWORDS('') -## TitleText1('') -## EditionText1('') -## AuthorText1('') -## Section1('') -## Problem1('') +## DBsubject(Probability) +## DBchapter(Random variables) +## DBsection(Discrete: probability mass function) +## KEYWORDS('Discrete Distribution', 'PDF') ## Author('Michael Stassen') ## Institution('Fitchburg State University') @@ -43,7 +38,7 @@ $p[7] = 1 - $s; @PDF = ([ '\(x\)', '\(P(X=x)\)' ]); -for $x (0 .. 10) { +for my $x (0 .. 10) { my $p = sprintf("%0.3f", $p[$x]); push(@PDF, [ $x, $p ]); } diff --git a/Contrib/Fitchburg/Probability/ice-cream.pg b/Contrib/Fitchburg/Probability/ice-cream.pg index 72e8829078..a6045a3ba2 100644 --- a/Contrib/Fitchburg/Probability/ice-cream.pg +++ b/Contrib/Fitchburg/Probability/ice-cream.pg @@ -1,5 +1,6 @@ # DESCRIPTION -# A problem that asks students to ... +# A problem that asks students to fill in a contingency table based on ice cream +# flavors and answer questions related to probabilities from the table. # # This problem is derived from a homework problem in Introductory Statistics, # licensed by OpenStax under a Creative Commons Attribution License (CC BY 4.0). @@ -9,6 +10,7 @@ ## DBsubject(Probability) ## DBchapter(Sample Space) ## DBsection(Probability: direct computation, inclusion/exclusion) +## KEYWORDS('contingency table') ## Institution(Fitchburg State University) ## Author(Rachael Norton) @@ -44,17 +46,17 @@ A soft-serve ice cream shop sold [$total] ice creams in a day. The following table identifies the ice creams they sold by flavor and whether they were served in a cup or cone. Fill in the missing values. -[@ DataTable( - [ - ['Flavor', 'Chocolate', 'Vanilla', 'Swirl', 'Strawberry', 'Total'], - ['Cup', $cupchocolate, PGML('[____]{$cupvanilla}'), $cupswirl, $cupstrawberry, $cup], - ['Cone', $conechocolate, $conevanilla, PGML('[____]{$coneswirl}'), $conestrawberry, PGML('[____]{$cone}')], - ['Total', PGML('[____]{$chocolate}'), $vanilla, PGML('[____]{$swirl}'), PGML('[____]{$strawberry}'), PGML('[____]{$total}')], - ], - padding => [0.5, 0.5], - align => '|c|c|c|c|c|c|', - horizontalrules => 1) -@]* +[# + [. .] [. Chocolate .] [. Vanilla .] [. Swirl .] [. Strawberry .] [. Total .]* + [. Cup .] [. [$cupchocolate] .] [. [_]{$cupvanilla} .] + [. [$cupswirl] .] [. [$cupstrawberry] .] [.[$cup].] + [. [$stream] .]* + [. Cone .] [. [$conechocolate] .] [. [$conevanilla] .] [. [_]{$coneswirl} .] + [. [$conestrawberry] .][. [_]{$cone} .]* + [. Total .] [. [_]{Real($chocolate)} .] [.[$vanilla].][. [_]{Real($swirl)} .] + [. [_]{$strawberry} .] [. [_]{Real($total)}.] +#]{ horizontalrules => 1, padding => [0.25, 0.25]} + a) What is the probability that a randomly selected ice cream was served in a cup? [____]{$cup/$total} b) What is the probability that a randomly selected ice cream was either chocolate or swirl? [____]{($chocolate+$swirl)/$total} @@ -63,4 +65,35 @@ d) What is the probability that a randomly selected ice cream was strawberry, gi e) What is the probability that a randomly selected ice cream was not chocolate? [____]{($total-$chocolate)/$total} END_PGML +BEGIN_PGML_SOLUTION +First, fill in the rest of the table, starting with rows or columns that are only +missing one value. Like the total Chocolate must be the sum in that column or +[$chocolate]. Continuing this, you will see that the table is: + +[# + [. .] [. Chocolate .] [. Vanilla .] [. Swirl .] [. Strawberry .] [. Total .]* + [. Cup .] [. [$cupchocolate] .] [. [$cupvanilla] .] + [. [$cupswirl] .] [. [$cupstrawberry] .] [.[$cup].] + [. [$stream] .]* + [. Cone .] [. [$conechocolate] .] [. [$conevanilla] .] [. [$coneswirl] .] + [. [$conestrawberry] .][. [$cone] .]* + [. Total .] [. [$chocolate] .] [.[$vanilla].][. [$swirl] .] + [. [$strawberry] .] [. [$total] .] +#]{ horizontalrules => 1, padding => [0.25, 0.25]} + + +To determine the probabilities, determine the number of instances that satify the condition and the divide by the total. + +a) [`` \frac{[$cup]}{[$total]} ``] + +b) [`` \frac{[$chocolate] + [$swirl]}{[$total]} = \frac{[$chocolate+$swirl]} +{[$total]} ``] + +c) [`` \frac{[$cup]}{[$total]} ``] + +d) [`` \frac{[$cupstrawberry]}{[$cup]}``] where the denominator is just the number of cups served. + +e) [`` 1- \frac{[$chocolate]}{[$total]} = \frac{[$total-$chocolate]}{[$total]} ``] +END_PGML_SOLUTION + ENDDOCUMENT(); diff --git a/Contrib/Fitchburg/Probability/living.pg b/Contrib/Fitchburg/Probability/living.pg index 30038ac58a..7fa62e9453 100644 --- a/Contrib/Fitchburg/Probability/living.pg +++ b/Contrib/Fitchburg/Probability/living.pg @@ -45,29 +45,41 @@ $ans3 = Fraction(100 - $b, 100); BEGIN_PGML One hundred nurses were surveyed about their living situation. The results of this survey are given in the following table. ->> -[@ DataTable([ - ['',PGML('_Renter_ ([`R`])'), PGML('_Homeowner_ ([`R^{\prime}`])'), PGML('_Total_')], - [PGML('Lives Alone [`A`]'),$a,$b,'50'], - [PGML('Does not live alone [`A^{\prime}`]'), $c, $d, '50'], - [PGML('Total'), $e, $f, 100] -], - padding => [0.5, 0.5], - align => '|l|c|c|c|', - horizontalrules => 1 - ) @]* << - +[# + [. .] [._Renter_ ([`R`]).] [. _Homeowner_ ([`R^{\prime}`]).]* + [.Lives Alone [`A`].] [.[$a].] [.[$b].] [.50.]* + [. Does not live alone [`A^{\prime}`] .] [.[$c].] [.[$d].] [. 50 .]* + [. Total .] [.[$e] .] [.[$f].] [.100.]* +#]{padding => [0.5, 0.5], horizontalrules => 1, texalignment => 'lccc'} If a nurse is selected at random from those surveyed, find the probability of each of the following events. a) The nurse is a renter or lives alone. + Answer: [_]{$ans1}{20} b) The nurse is a homeowner or does not live alone. + Answer: [_]{$ans2}{20} c) The nurse is a renter or does not live alone. + Answer: [_]{$ans3}{20} END_PGML +BEGIN_PGML_SOLUTION +For each of these, we need to find the total number of nurses that are listed in +the table with the given statement. +a) The total number of nurses that rent or live alone is [`[$a]+[$b] +[$c] = [@ 100-$d @] `], +so [`` P(A\text{ or }R) = \frac{[@100-$d@]}{100} ``] + +b) The total number of nurses that owns a home or does not live alone is +[`[$b] + [$d] + [$c] = [@100-$a@] `] so +[``P(R'\text{ or }A') = \frac{[@100-$a@]}{100}``] + +c) The total number of nurses that rents or does not live along is +[`[$a]+[$c]+[$d] = [@100-$b@]`] therefore +[``P(R\text{ or }A') = \frac{[@100-$b@]}{100}``] +END_PGML_SOLUTION + ENDDOCUMENT(); diff --git a/Contrib/Fitchburg/Probability/prob-cards-01.pg b/Contrib/Fitchburg/Probability/prob-cards-01.pg index 17ba265058..e8757c7899 100644 --- a/Contrib/Fitchburg/Probability/prob-cards-01.pg +++ b/Contrib/Fitchburg/Probability/prob-cards-01.pg @@ -24,8 +24,7 @@ Context('Fraction'); random_subset(2, 'red', 'gray', 'yellow', 'blue', 'purple'); do { - $num1 = random(5, 9); - $num2 = random(5, 9); + ($num1, $num2) = (random(5, 9), random(5, 9)); } until ($num1 != $num2); $total = $num1 + $num2; @@ -56,4 +55,25 @@ e) [`P(G|E)`] = [__]{$ans5} f) [`P(E|G)`] = [__]{$ans6} END_PGML +BEGIN_PGML_SOLUTION +a) Since there are [$num1] [$color1] cards out of a total of [$total] cards, then +[``` P(G) = \frac{[$num1]}{[$total]} ```] + +b) There are [$even1+$even2] even cards so +[``` P(E) = [$ans2] ```] + +c) There are [$even1] [$color1] even cards so +[``` P(G\text{ and }E) = [$ans3] ```] + +d) The total [$color1] or even cards need to be counted. There are [$num1] [$color1] cards and [$even2] even [$color2] cards, so +[``` P(G\text{ or }E) = \frac{[$num1]+[$even2]}{[$total]} = [$ans4] ```] + +e) This is the probability that the card is [$color1] given that it is even. There are [$even1+$even2] even cards and of those [$even1] are [$colo1], so +[``` P(G|E) = \frac{[$even1]}{[$even1+$even2]} ```] + +f) This is the probability that the card is even given that the card is [$color1]. +There are [$num1] [$color1] cards and of those [$even1] are even. Thus +[``` P(E|G) = \frac{[$even1]}{[$num1]} ```] +END_PGML_SOLUTION + ENDDOCUMENT(); diff --git a/Contrib/Fitchburg/Probability/prob-cards-02.pg b/Contrib/Fitchburg/Probability/prob-cards-02.pg index 4165595a8f..d7f4332076 100644 --- a/Contrib/Fitchburg/Probability/prob-cards-02.pg +++ b/Contrib/Fitchburg/Probability/prob-cards-02.pg @@ -23,8 +23,8 @@ Context('Fraction'); ($color1, $color2) = random_subset(2, 'red', 'gray', 'yellow', 'blue', 'purple'); -$num1 = random(5, 11, 1); -$num2 = random(3, $gray, 1); +$num1 = random(5, 11,); +$num2 = random(3, $gray); $total = $num1 + $num2; $ans1 = Fraction($num1**2, $total**2); @@ -45,5 +45,18 @@ b) [`P(E)`] = [__]{$ans2} c) [`P(G_2|G_1)`] = [__]{$ans3} END_PGML +BEGIN_PGML_SOLUTION +a) [`` P(G_1) = \frac{[$num1]}{[$total]} ``] and since the cards are replaced, [`` P(G_2) = \frac{[$num1]}{[$total]} ``] and since these are independent, +[``` P(G_1\text{ and }G_2) = P(G_1) \cdot P(G_2) = + \left(\frac{[$num1]}{[$total]}\right)^2 = [$ans1] ```] + +b) The probability that at least one card is blue is most easily found by +the complement of part a) or [``P(E) = 1- P(G_1\text{ and }G_2) = 1- [$ans1] = [$ans2] ``] + +c) [`P(G_2|G_1)`] is the probability that the second card is green given that +the first one was green. Since these are independent, this is just [` P(G_2)`] or +[`[$ans3]`]. +END_PGML_SOLUTION + ENDDOCUMENT(); diff --git a/Contrib/Fitchburg/Probability/proportions-pets.pg b/Contrib/Fitchburg/Probability/proportions-pets.pg index 59f07f2379..0be4d9afed 100644 --- a/Contrib/Fitchburg/Probability/proportions-pets.pg +++ b/Contrib/Fitchburg/Probability/proportions-pets.pg @@ -15,7 +15,7 @@ DOCUMENT(); -loadMacros("PGstandard.pl", "Parser.pl", "Stats.pl", "PGML.pl"); +loadMacros("PGstandard.pl", "Parser.pl", "PGML.pl"); Context("LimitedNumeric"); @@ -32,14 +32,26 @@ Overall, [$p] percent of students at Mythic University have pets. [$n] randomly Enter each requested value. Proportions should be entered with two decimal points of precision. -[` n `] = [_]{$n} +a) [` n `] = [_]{$n} -[` x `] = [_]{$x} +b) [` x `] = [_]{$x} -[` p `] = [_]{$pprop} +c) [` p `] = [_]{$pprop} -[` \hat{p} `] = [_]{$phatprop} +d) [` \hat{p} `] = [_]{$phatprop} END_PGML +BEGIN_PGML_SOLUTION + +a) This is the total number of students in the sample or [$n]. + +b) This is the toal number of students with pets and this is [$x]. + +c) This is the population proportion and since the problem says [$p] percent, then +this is [$pprop]. + +d) This is sample proportion and this is [`\frac{[$x]}{[$n]} `] +END_PGML_SOLUTION + ENDDOCUMENT(); diff --git a/Contrib/Fitchburg/Probability/siblings_rel_freq.pg b/Contrib/Fitchburg/Probability/siblings_rel_freq.pg index de18a9b2b0..c8e717d10d 100644 --- a/Contrib/Fitchburg/Probability/siblings_rel_freq.pg +++ b/Contrib/Fitchburg/Probability/siblings_rel_freq.pg @@ -1,9 +1,15 @@ +## DBsubject(Probability) +## DBchapter(Sample Space) +## DBsection(Probability: direct computation, inclusion/exclusion) +## KEYWORDS('relative frequencey', 'probability') +## Level(1) DOCUMENT(); loadMacros("PGstandard.pl", "PGML.pl", "niceTables.pl", "contextPercent.pl"); Context("LimitedNumeric"); -loadMacros("fixedPrecision.pl"); # must come after Context is set. +loadMacros("fixedPrecision.pl", 'PGcourse.pl') + ; # must come after Context is set. $total = random(40, 50, 10); @@ -16,7 +22,7 @@ $freq[2] = $total - $subtotal; @rf = map { FixedPrecision($_ / $total, 3); } @freq; $crf[0] = FixedPrecision(100 * $rf[0], 1); -for $i (1 .. 5) { +for my $i (1 .. 5) { $crf[$i] = FixedPrecision($crf[ $i - 1 ] + 100 * $rf[$i], 1); } diff --git a/Contrib/Fitchburg/Probability/tree-diagram.pg b/Contrib/Fitchburg/Probability/tree-diagram.pg index de800c1bf8..11b6a2bb32 100644 --- a/Contrib/Fitchburg/Probability/tree-diagram.pg +++ b/Contrib/Fitchburg/Probability/tree-diagram.pg @@ -7,16 +7,21 @@ ## DBchapter(Sample Space) ## DBsection(Probability: direct computation, inclusion/exclusion) ## Institution(Fitchburg State University) +## KEYWORDS('random','with replacement') ## Author(Peter Staab) ## Level(1) DOCUMENT(); -loadMacros('PGstandard.pl', 'PGML.pl', 'PGtikz.pl', 'contextPercent.pl', 'PGcourse.pl'); +loadMacros( + 'PGstandard.pl', 'PGML.pl', + 'PGtikz.pl', 'contextPercent.pl', + 'PGcourse.pl' +); Context('Numeric'); -$red = random(2,4); -$green = random(5,7); +$red = random(2, 4); +$green = random(5, 7); $graph = createTikZImage(); $graph->tikzLibraries('arrows.meta'); @@ -40,10 +45,17 @@ $graph->BEGIN_TIKZ \draw(5.5,2.5) -- (5.5,1.5) node [below] {j GG}; END_TIKZ +$alt_text = + "A tree diagram with the top level two branches. The left is labeled 'a R' " + . "and the second is labeled 'b G'. Each of these is branched. The left branch " + . "branches in two to 'c R' and 'd G'. The right branch splits to 'e R' and 'f G'. " + . "Each of the four branches continue directly below. The bottom row is labeled " + . "'g RR', 'h RG', 'i GR' and 'j GG'."; + Context('Percent'); -$ans1 = Real(($red/($red+$green))**2); -$ans2 = Real(2*$red*$green/($red+$green)**2); +$ans1 = Real(($red / ($red + $green))**2); +$ans2 = Real(2 * $red * $green / ($red + $green)**2); BEGIN_PGML A bag contains [$red] red and [$green] green marbles. Marbles are selected randomly from @@ -51,7 +63,7 @@ the bag *with* replacement. Consider the following tree diagram -[! !]{$graph}{400} +>> [! [$alt_text] !]{$graph}{400} << where [`a, b, c, d, e, f, g, h, i`] and [`j`] are whole numbers. Based on this problem, find these numbers; @@ -65,7 +77,7 @@ g) [_]{Real($red*$red)} h) [_]{Real($green*$red)} i) [_]{Real($green*$red)} -j: [_]{Real($red*$red)} + j. [_]{Real($red*$red)} Also, calclulate the following: @@ -74,4 +86,21 @@ b) [`P(RG\text{ or } GR) = `] [_]{Real($ans2)} END_PGML +BEGIN_PGML_SOLUTION +The top two are just the number of red and green marbles so a) is [$red] and b) is [$blue]. + +The next level is the same so c) is [$red] d) is [$green], e) is [$red] and f) is [$green]. + +The last level is just the product of the number of red and green, so +g) is [$red*$red], h) is [$red*$green] i) is [$red*$green] and j) is [$red*$red]. + +Notice that the sum along the bottom row is +[`[$red*$red] + [$red*$green]+[$green*$red] + [$green*$green] = [@ ($red+$green)**2 @] `] + +a) [`P(RR) = \frac{[$red*$red]}{[@ ($red+$green)**2 @]} = [$ans1] `] + +b) [`P(RG\text{ or } GR) = \frac{[$red*$green]+[$green*$red]}{[@ ($red+$green)**2 @]} + = [$ans2]`] +END_PGML_SOLUTION + ENDDOCUMENT(); diff --git a/Contrib/Fitchburg/Statistics/Basics/basic-definitions.pg b/Contrib/Fitchburg/Statistics/Basics/basic-definitions.pg index cb64686558..7f81123f53 100644 --- a/Contrib/Fitchburg/Statistics/Basics/basic-definitions.pg +++ b/Contrib/Fitchburg/Statistics/Basics/basic-definitions.pg @@ -1,7 +1,7 @@ # DESCRIPTION # A problem that asks students to determine the population, variable, # data, sample, statistic and parameter from a situation. -# + # This problem is derived from a homework problem in Introductory Statistics, # licensed by OpenStax under a Creative Commons Attribution License (CC BY 4.0). # Modified for WeBWorK by Michael Stassen mstassen(at)fitchburgstate(dot)edu @@ -10,62 +10,60 @@ ## DBsubject(Statistics) ## DBchapter(Experimental design) ## DBsection(Concepts) +## Keywords('population', 'variable', 'sample', 'parameter','statistic') ## Institution(Fitchburg State University) ## Author(Michael Stassen) DOCUMENT(); -loadMacros( -"PG.pl", -"PGbasicmacros.pl", -"PGchoicemacros.pl", -"PGanswermacros.pl", -"unionTables.pl", -"PGML.pl", -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); -TEXT(beginproblem()); -$ml = new_match_list(); -$ml->qa( -"Population", "All clients of the fitness center", -"Variable", "Amount of time a client exercises in the center in a week", -"Sample", "The 50 randomly selected clients", -"Parameter", "The mean amount of time a client exercises in the center per week", -"Data", "The 50 recorded amounts of time", -"Statistic", "The mean amount of time the 50 selected clients exercise in the center per week" +@terms = ('Population', 'Variable', 'Sample', 'Parameter', 'Data', 'Statistic'); +@answers = ( + 'All clients of the fitness center', + 'Amount of time a client exercises in the center in a week', + 'The 50 randomly selected clients', + 'The mean amount of time a client exercises in the center per week', + 'The 50 recorded amounts of time', + 'The mean amount of time the 50 selected clients exercise in the center per week' +); +@other = ( + "People who exercise", + "All clients of fitness centers", + 'None of the Above' ); -# use pop-up-lists -$ml->rf_print_q(~~&pop_up_list_print_q); -# you may need to add more letters D=>"D", etc. -$ml->ra_pop_up_list([No_answer=>"?",A=>"A",B=>"B",C=>"C", D=>"D", E=>"E",F=>"F", G=>"G",H=>"H", I=>"I"]); -$ml->choose(6); - -$ml->extra("People who exercise", "All clients of fitness centers", ); -$ml->choose_extra(2); +@all = (@answers, @other); -$ml->makeLast("None of the above"); - -BEGIN_PGML -A fitness center is interested in the mean amount of time a client exercises in the center per week. They randomly select 50 clients and record their time spent exercising for a week. -Match each term with the corresponding part of the study. -[@ ColumnMatchTable($ml) @]*** -END_PGML +@shuffle = random_subset(8, 0 .. 7); +%shuff = (map { $_ => $shuffle[$_] } (0 .. 7)); +for my $i (0 .. 5) { + @index = grep { $shuff{$_} == $i } (0 .. 7); + $invshuffle[$i] = $index[0]; +} -# no credit until all answers are correct -install_problem_grader(~~&std_problem_grader); -$showPartialCorrectAnswers = 1; +@dd = map { DropDown([ 'A' .. 'I' ], $invshuffle[$_]) } (0 .. 5); -ANS( str_cmp( $ml->ra_correct_ans ) ); +$showPartialCorrectAnswers = 0; -# the remainder of the code is included to -# provide a sensible solution for the -# student. +BEGIN_PGML +A fitness center is interested in the mean amount of time a client exercises in +the center per week. They randomly select 50 clients and record their time spent exercising for a week. Match each term with the corresponding part of the study. + +[# + [. **1.** [_]{$dd[0]} [$terms[0]].] [. **A.** [$all[$shuffle[0]]] .]* + [. **2.** [_]{$dd[1]} [$terms[1]] .] [. **B.** [$all[$shuffle[1]]] .]* + [. **3.** [_]{$dd[2]} [$terms[2]] .] [. **C.** [$all[$shuffle[2]]] .]* + [. **4.** [_]{$dd[3]} [$terms[3]] .] [. **D.** [$all[$shuffle[3]]] .]* + [. **5.** [_]{$dd[4]} [$terms[4]] .] [. **E.** [$all[$shuffle[4]]] .]* + [. **6.** [_]{$dd[5]} [$terms[5]] .] [. **F.** [$all[$shuffle[5]]] .]* + [. .] [. **G.** [$all[$shuffle[6]]] .]* + [. .] [. **H.** [$all[$shuffle[7]]] .]* + [. .] [. **I.** [$all[8]] .]* +#]{texalignment => 'll'} -# the answers to the questions that were -# asked, in order, are -@correctAns = @{$ml->ra_correct_ans}; +END_PGML # the following becomes necessary if we want # to figure out what questions were asked @@ -75,33 +73,21 @@ ANS( str_cmp( $ml->ra_correct_ans ) ); # explanations that correspond to the # list of questions we might have asked @explanations = ( -"the population is the complete group of interest", -"each member of the population or sample has a value of the variable", -"the sample is the selected subset of the population", -"a parameter is a descriptive measure of the population", -"the data is the set of recorded values of the variable", -"a statistic is a descriptive measure of the sample data" + "the population is the complete group of interest", + "each member of the population or sample has a value of the variable", + "the sample is the selected subset of the population", + "a parameter is a descriptive measure of the population", + "the data is the set of recorded values of the variable", + "a statistic is a descriptive measure of the sample data" ); -# then find the questions that were asked -@askedQuestions = (); -foreach $q ( @{$ml->selected_q} ) { - $i = 0; - foreach $mq ( @{$ml->questions} ) { - if ( $q eq $mq ) { - push(@askedQuestions, $i); - last; - } - $i++; - } -} BEGIN_PGML_SOLUTION -1. The answer is [$correctAns[0]], because [$explanations[$askedQuestions[0]]]. -2. The answer is [$correctAns[1]], because [$explanations[$askedQuestions[1]]]. -3. The answer is [$correctAns[2]], because [$explanations[$askedQuestions[2]]]. -4. The answer is [$correctAns[3]], because [$explanations[$askedQuestions[3]]]. -5. The answer is [$correctAns[4]], because [$explanations[$askedQuestions[4]]]. -6. The answer is [$correctAns[5]], because [$explanations[$askedQuestions[5]]]. +1. The answer is [$dd[0]], because [$explanations[0]]. +2. The answer is [$dd[1]], because [$explanations[1]]. +3. The answer is [$dd[2]], because [$explanations[2]]. +4. The answer is [$dd[3]], because [$explanations[3]]. +5. The answer is [$dd[4]], because [$explanations[4]]. +6. The answer is [$dd[5]], because [$explanations[5]]. END_PGML_SOLUTION diff --git a/Contrib/Fitchburg/Statistics/Basics/definition-population.pg b/Contrib/Fitchburg/Statistics/Basics/definition-population.pg index f7b07dc8c3..f98ebc7631 100644 --- a/Contrib/Fitchburg/Statistics/Basics/definition-population.pg +++ b/Contrib/Fitchburg/Statistics/Basics/definition-population.pg @@ -9,6 +9,7 @@ ## DBsubject(Statistics) ## DBchapter(Experimental design) ## DBsection(Concepts) +## KEYWORDS('population','mean') ## Institution(Fitchburg State University) ## Author(Michael Stassen) diff --git a/Contrib/Fitchburg/Statistics/ConfidenceIntervals/8_3_1_RMN.pg b/Contrib/Fitchburg/Statistics/ConfidenceIntervals/8_3_1_RMN.pg index 77b3bb4ec8..bf77a6c568 100644 --- a/Contrib/Fitchburg/Statistics/ConfidenceIntervals/8_3_1_RMN.pg +++ b/Contrib/Fitchburg/Statistics/ConfidenceIntervals/8_3_1_RMN.pg @@ -11,6 +11,7 @@ ## DBsection(One sample mean - z) ## Institution(Fitchburg State University) ## Author(Michael Stassen) +## KEYWORDS('confidence interval', 'sample size','sample proportion') DOCUMENT(); loadMacros( @@ -20,7 +21,6 @@ loadMacros( ); Context("LimitedNumeric"); -loadMacros("fixedPrecision.pl"); # must come after Context is set. $conf = list_random(90, 95); $alpha = 1 - $conf / 100; @@ -56,4 +56,13 @@ d. The [$conf]% confidence interval is from [____]{$p1} to [____]{$p2}. END_PGML +BEGIN_PGML_SOLUTION +a. The sample size is [$n]. +b. The sample proportion is [`\hat{p}=\frac{[$x]}{[$n]}=[$p]`] +c. For a [$conf]% confidence interval, we use the corresponding [`z`]-score of [`z^{\star}=`][$z] and the margin of error is +[``` SE \sqrt{\frac{\hat{p}(1-\hat{p})} {n}} = [$E]```] +d. For the confidence error, the formula is +[``` \hat{p} \pm SE = ([$p1],[$p2])```] +END_PGML_SOLUTION + ENDDOCUMENT(); diff --git a/Contrib/Fitchburg/Statistics/ConfidenceIntervals/8_3_2_RMN.pg b/Contrib/Fitchburg/Statistics/ConfidenceIntervals/8_3_2_RMN.pg index 1bd19281bf..aad260af85 100644 --- a/Contrib/Fitchburg/Statistics/ConfidenceIntervals/8_3_2_RMN.pg +++ b/Contrib/Fitchburg/Statistics/ConfidenceIntervals/8_3_2_RMN.pg @@ -9,6 +9,7 @@ ## DBsubject(Statistics) ## DBchapter(Confidence intervals) ## DBsection(One sample mean - z) +## KEYWORDS('sample proportion','margin of error', 'confidence interval') ## Institution(Fitchburg State University) ## Author(Michael Stassen) @@ -20,16 +21,14 @@ loadMacros( ); Context("LimitedNumeric"); -loadMacros("fixedPrecision.pl"); # must come after Context is set. $conf = list_random(90, 95, 99); $alpha = 1 - $conf / 100; -$x = random(310, 330, 1); +$x = random(310, 330); $n = 400; -Context("Percent"); -Context()->flags->set( +Context("Percent")->flags->set( decimalPlaces => 1, tolerance => .1, ); @@ -57,4 +56,13 @@ c. The [$conf]% confidence interval is from [____]{$p1} to [____]{$p2}. END_PGML +BEGIN_PGML_SOLUTION + +a. The sample proportion is [`\hat{p}=\frac{[$x]}{[$n]}=`][$p] +b. For a [$conf]% confidence interval, we use the corresponding [`z`]-score of [`z^{\star}=`][$z] and the margin of error is +[``` SE \sqrt{\frac{\hat{p}(1-\hat{p})} {n}} = [$E]```] +c. For the confidence error, the formula is +[``` \hat{p} \pm SE = ([$p1],[$p2])```] +END_PGML_SOLUTION + ENDDOCUMENT(); diff --git a/Contrib/Fitchburg/Statistics/Descriptive/line-graph.pg b/Contrib/Fitchburg/Statistics/Descriptive/line-graph.pg index 3c66be13e0..68f482f3ec 100644 --- a/Contrib/Fitchburg/Statistics/Descriptive/line-graph.pg +++ b/Contrib/Fitchburg/Statistics/Descriptive/line-graph.pg @@ -1,32 +1,45 @@ ## DESCRIPTION -## Give a value for pi +## Construct a line graph for a dataset. ## ENDDESCRIPTION -## KEYWORDS('template', 'pi') +## KEYWORDS('line graph', 'dataset') -## DBsubject('Algebra') -## DBchapter('Fundamentals') -## DBsection('Real Numbers') -## Date('') -## Author('') -## Institution('') +## DBsubject(Statistics) +## DBchapter(Exploratory data analysis/descriptive statistics) +## DBsection(Graphical representations) +## Date('07/01/2024') +## Author('Peter Staab') +## Institution('Fitchburg State University') DOCUMENT(); -loadMacros('PGstandard.pl','PGML.pl','parserGraphTool.pl','randomPerson.pl', 'niceTables.pl', 'PGcourse.pl'); +loadMacros( + 'PGstandard.pl', 'PGML.pl', + 'parserGraphTool.pl', 'randomPerson.pl', + 'niceTables.pl', 'PGcourse.pl' +); $p_first = randomPerson(); -$p_last = randomLastName(); - -@q = (random(1,3), random(2,4), random(2,5), random(3,6), random(2,7), random(0,3)); +$p_last = randomLastName(); + +@q = ( + random(1, 3), + random(2, 4), + random(2, 5), + random(3, 6), + random(2, 7), + random(0, 3) +); $tab = DataTable([ - [['Number of Correct Questions' , rowheader => 1], 'Number of Students'], - map { [$_, $q[$_]] } (0..5) - ] - ); + [ + [ 'Number of Correct Questions', headerrow => 1 ], + 'Number of Students', + ], + map { [ $_, $q[$_] ] } (0 .. 5) +]); -$str = join ', ', map { "{point, ($_, $q[$_])}" } (0..5); +$str = join ', ', map {"{point, ($_, $q[$_])}"} (0 .. 5); $gt = GraphTool($str)->with( availableTools => ['PointTool'], @@ -42,13 +55,15 @@ Professor [$p_last] [@ $p_first->verb('give') @] [$p_first->their] class a pop q Construct a line graph below using the point below. Note: the line will not be drawn between the points. -[_]{$gt} +>>[_]{$gt} << END_PGML BEGIN_PGML_SOLUTION -[@ $gt->generateAnswerGraph @]* +Place a point on each coordinate point from the table. + +>>[@ $gt->generateAnswerGraph @]*<< END_PGML_SOLUTION ENDDOCUMENT(); diff --git a/Contrib/Fitchburg/Statistics/Descriptive/quantiles.pg b/Contrib/Fitchburg/Statistics/Descriptive/quantiles.pg index 5436cd3f6a..50040e3984 100644 --- a/Contrib/Fitchburg/Statistics/Descriptive/quantiles.pg +++ b/Contrib/Fitchburg/Statistics/Descriptive/quantiles.pg @@ -1,3 +1,14 @@ +## DESCRIPTION +## Find the first, second and third quartiles of a sorted dataset. +## ENDDESCRIPTION +## DBsubject(Statistics) +## DBchapter(Exploratory data analysis/descriptive statistics) +## DBsection(Graphical representations) +## Institution(Fitchburg State University) +## KEYWORDS('quartiles') +## Author(Peter Staab) +## Date(07/01/2022) + DOCUMENT(); loadMacros("PGstandard.pl", "PGML.pl", "PGstatisticsmacros.pl", 'PGcourse.pl'); @@ -8,46 +19,51 @@ $n = random(15, 25, 2); sub q_index { my ($p, $n) = @_; - my $i = $p * ($n + 1); - return $i; + return $p * ($n + 1); } sub quantile { my ($i, @sorted) = @_; - my $j = int($i); - my $q; - if ($j == $i) { - $q = $sorted[ $j - 1 ]; - } else { - $q = ($sorted[ $j - 1 ] + $sorted[$j]) / 2; - } - return $q; + return $i == int($i) + ? $sorted[ int($i) - 1 ] + : ($sorted[ int($i) - 1 ] + $sorted[ int($i) ]) / 2; } $i1 = q_index(.25, $n); -$Q1 = quantile($i1, @sorted); +$Q1 = quantile($i1, @data); $i2 = q_index(.50, $n); -$Q2 = quantile($i2, @sorted); +$Q2 = quantile($i2, @data); $i3 = q_index(.75, $n); -$Q3 = quantile($i3, @sorted); +$Q3 = quantile($i3, @data); BEGIN_PGML Exam scores for [$n] randomly selected students were recorded. Here are the scores in ascending order: [@ join(', ', @data) @] + +Let [`i`] be the index of the given quartile. + a) Find the first quartile. - [`i`] = [____]{$i1} - [`Q_1`] = [____]{$Q1} + [`i`] = [____]{Compute($i1)} + [`Q_1`] = [____]{Compute($Q1)} b) Find the second quartile. - [`i`] = [____]{$i2} - [`Q_2`] = [____]{$Q2} + [`i`] = [____]{Compute($i2)} + [`Q_2`] = [____]{Compute($Q2)} c) Find the third quartile. - [`i`] = [____]{$i3} - [`Q_3`] = [____]{$Q3} + [`i`] = [____]{Compute($i3)} + [`Q_3`] = [____]{Compute($Q3)} END_PGML +BEGIN_PGML_SOLUTION +The second quartile is just the median. In this case, since the number of points is odd, the second quartile is the middle value. Also, the first quartile is the middle of the smaller half and the third quartile is the larger half. + +a) [` i = [$i1], Q_1 = [$Q1] `] +b) [` i = [$i2], Q_1 = [$Q2] `] +c) [` i = [$i3], Q_1 = [$Q3] `] +END_PGML_SOLUTION + ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/Contrib/Fitchburg/Statistics/Descriptive/stem-leaf.pg b/Contrib/Fitchburg/Statistics/Descriptive/stem-leaf.pg index 1a337fa6fb..33ec7b146f 100644 --- a/Contrib/Fitchburg/Statistics/Descriptive/stem-leaf.pg +++ b/Contrib/Fitchburg/Statistics/Descriptive/stem-leaf.pg @@ -1,15 +1,13 @@ ## DESCRIPTION -## Give a value for pi +## Produce a table used to create a stem-and-leaf plot ## ENDDESCRIPTION - -## KEYWORDS('template', 'pi') - -## DBsubject('Algebra') -## DBchapter('Fundamentals') -## DBsection('Real Numbers') -## Date('') -## Author('') -## Institution('') +## DBsubject(Statistics) +## DBchapter(Exploratory data analysis/descriptive statistics) +## DBsection(Graphical representations) +## Institution(Fitchburg State University) +## KEYWORDS('stem and leaf plot') +## Author(Peter Staab) +## Date(07/01/2022) DOCUMENT(); @@ -23,39 +21,42 @@ loadMacros('PGstandard.pl', 'PGML.pl', 'niceTables.pl', 'PGcourse.pl'); @leaf5 = num_sort(map { $_ % 10 } grep { 50 <= $_ && $_ < 60 } @x); @leaf6 = num_sort(map { $_ % 10 } grep { 60 <= $_ && $_ < 70 } @x); -$tab = DataTable([ - [ [ 'stem', headerrow => 1 ], 'leaf' ], - [ 2, PGML('[_]{List(@leaf2)->cmp(ordered => 1)}') ], - [ PGML('[_]{Real(3)}'), PGML('[_]{List(@leaf3)->cmp(ordered => 1)}') ], - [ PGML('[_]{Real(4)}'), PGML('[_]{List(@leaf4)->cmp(ordered => 1)}') ], - [ PGML('[_]{Real(5)}'), PGML('[_]{List(@leaf5)->cmp(ordered => 1)}') ], - [ 6, PGML('[_]{List(@leaf6)->cmp(ordered => 1)}') ], -]); - BEGIN_PGML Consider the dataset [``` [@ join(', ',@x) @] ```] Fill in the following stem and leaf plot: -[$tab]* +[# + [.stem.][.leaf.]{headerrow => 1}* + [. 2 .] [.[_]{List(@leaf2)->cmp(ordered => 1)} .]* + [. [_]{3} .] [.[_]{List(@leaf3)->cmp(ordered => 1)}.]* + [. [_]{4} .] [.[_]{List(@leaf4)->cmp(ordered => 1)}.]* + [. [_]{5} .] [.[_]{List(@leaf5)->cmp(ordered => 1)}.]* + [. 2 .] [.[_]{List(@leaf6)->cmp(ordered => 1)}.]* +#] The numbers in the leaves should be ordered and separated by commas. END_PGML -$sol_table = DataTable([ - [ [ 'stem', headerrow => 1 ], 'leaf' ], - [ 2, join(', ', @leaf2) ], - [ 3, join(', ', @leaf3) ], - [ 4, join(', ', @leaf4) ], - [ 5, join(', ', @leaf5) ], - [ 6, join(', ', @leaf6) ], -]); +$sol_table = DataTable( + [ + [ [ 'stem', headerrow => 1 ], 'leaf' ], + [ 2, join(', ', @leaf2) ], + [ 3, join(', ', @leaf3) ], + [ 4, join(', ', @leaf4) ], + [ 5, join(', ', @leaf5) ], + [ 6, join(', ', @leaf6) ], + ], + align => 'll' +); BEGIN_PGML_SOLUTION Recall for a Stem and Leaf plot, the stem is the first digit and the leaves are the second digit. In this case, + + [$sol_table]* END_PGML_SOLUTION diff --git a/Contrib/Fitchburg/Statistics/Distributions/6_2_RMN.pg b/Contrib/Fitchburg/Statistics/Distributions/6_2_RMN.pg index d1932b2624..ec8b13e71c 100644 --- a/Contrib/Fitchburg/Statistics/Distributions/6_2_RMN.pg +++ b/Contrib/Fitchburg/Statistics/Distributions/6_2_RMN.pg @@ -1,5 +1,6 @@ # DESCRIPTION -# A problem that asks students to ... +# A problem that asks students to find the values of probabilities under the +# normal curve. # # This problem is derived from a homework problem in Introductory Statistics, # licensed by OpenStax under a Creative Commons Attribution License (CC BY 4.0). @@ -9,17 +10,14 @@ ## DBsubject(Probability) ## DBchapter(Continuous distributions) ## DBsection(Gaussian normal) +## KEYWORDS('normal distribution','percentile') ## Institution(Fitchburg State University) ## Author(Michael Stassen) DOCUMENT(); loadMacros( - 'PGstandard.pl', - "PGML.pl", - "contextPercent.pl", - "PGnumericalmacros.pl", - "PGstatisticsmacros.pl", - # "Stats.pl", + 'PGstandard.pl', 'PGML.pl', + 'contextPercent.pl', 'PGstatisticsmacros.pl', 'PGcourse.pl' ); @@ -38,11 +36,11 @@ $Pa = normal_prob($Za, 'infty'); $b = random(1, 5); $Zb = normal_distr(.5 - $b / 100); -$Xb = $mu + $sigma * 1.75; +$Xb = $mu + $sigma * $Zb; $d = random(15, 30, 5); $Zd = normal_distr(.5 - $d / 100); -$Xd = $mu - $sigma * .84; +$Xd = $mu - $sigma * $Zd; $m = random(50, 90, 10); $Zm = normal_distr($m / 200); @@ -53,10 +51,43 @@ BEGIN_PGML IQ is normally distributed with a mean of [$mu] and a standard deviation of [$sigma]. Suppose one individual is randomly chosen. -b. Find the probability that the person has an IQ greater than [$a].[____]{$Pa} -c. Find the minimum IQ to be in the top 4% of all IQs. [____]{$Xb} -d. Find the 20th Percentile (20% of IQs are less than this value). [____]{$Xd} +a. Find the probability that the person has an IQ greater than [$a].[____]{$Pa} +b. Find the minimum IQ to be in the top [$b]% of all IQs. [____]{$Xb} +d. Find the 20th Percentile ([$d]% of IQs are less than this value). [____]{$Xd} END_PGML +BEGIN_PGML_SOLUTION +These questions ask for probabilities values on a normal distribution. If one has access +to software that allows one to look up the values on non-standard normal, these answers +can typically be just entered in the software. + +If only the standard normal is available, recall to convert to the standard normal, use +the [`z`]-score or +[``` z = \frac{x - \mu}{\sigma} = \frac{x-[$mu]}{[$sigma]}. ```] + +Lastly, if only the left tail of the normal curve is known (which is common), recall that +[``` P(a \leq Z \leq b) = P(Z \leq b) - P(Z \leq a) ```] + +a) [`` P(X > [$a]) = 1 - P(X < [$a]) = [$Pa] ``] + +b) In this case, we seek [`a`] such that [` P(X>a) = [@ $b*0.01@]`]. This may be +needed to be changed to [` P (X [$b]) = [$Pb]`] +c. Find [`P([$c] < X < [$c]) = [$Pcd] `] +d. One needs the value [`a`] such that [`P(Z < a) = 0.9 `] on the standard +normal curve. This can be found to be [`a=[$Zk]`] and then converting to the given +distribution with +[``` x = \mu + a \sigma = [$mu] + [$Zk] \cdot [$sigma] = [$Xk] ```] +e. First, one needs to find the value of [`a`] such that [` P(-a < Z< a = [$m/100])`] on +the standard normal curve. This can be done easier knowing that there is [@ 1-$m/100 @] in the two tails and thus [@ (1-$m/100)*0.5 @] in one tail so that +[``` P(-a < Z < a) = [$m/100]```] +is true for the same value of [`a`] as +[``` P(Z71)`] which again can be found directly or using the standard normal +which results in [`P(Z > [$Zm])`]. Either technique results in [$Pc]. +END_PGML_SOLUTION + ENDDOCUMENT(); diff --git a/Contrib/Fitchburg/Statistics/Distributions/normal-01.pg b/Contrib/Fitchburg/Statistics/Distributions/normal-01.pg index 77cc54f914..24a9d2b521 100644 --- a/Contrib/Fitchburg/Statistics/Distributions/normal-01.pg +++ b/Contrib/Fitchburg/Statistics/Distributions/normal-01.pg @@ -41,4 +41,18 @@ e. [`P(Z < [$f]) = `][____]{Percent(normal_prob(-'infty',$f))} END_PGML +BEGIN_PGML_SOLUTION +These are all standard normal and can either be looked up in table or using software. +There may be needed to convert to a different tail. For example, if you have +a right tail, to switch to a left tail with +[``` P(X>a) = 1- P(X`] and [`\geq`]. + +a) [@normal_prob(-'infty',$a)@] +b) [@normal_prob($a,'infty')@] +c) [@normal_prob($b,'infty')@] +d) [@normal_prob($e,'infty')@] +e) [@normal_prob(-'infty',$f)@] +END_PGML_SOLUTION + ENDDOCUMENT(); diff --git a/Contrib/Fitchburg/Statistics/Distributions/pz_2_RMN.pg b/Contrib/Fitchburg/Statistics/Distributions/pz_2_RMN.pg index ec20205746..4edb755942 100644 --- a/Contrib/Fitchburg/Statistics/Distributions/pz_2_RMN.pg +++ b/Contrib/Fitchburg/Statistics/Distributions/pz_2_RMN.pg @@ -52,4 +52,14 @@ b. [`P([$c] \le Z \le [$d]) = `][____]{Percent($Pcd)} END_PGML +BEGIN_PGML_SOLUTION +Depending on the tools that you have, these can be found exactly using software or if your software (or tables) only has a left tail, which is common, you'll need to +use +[``` P(a \leq X \leq b) = P(X \geq b) - P(X \geq a). ```] + +In either case, +a) [$Pab] +b) [$Pcd] +END_PGML_SOLUTION + ENDDOCUMENT(); diff --git a/OpenProblemLibrary/CollegeOfIdaho/setAlgebra_04_01_LinearInequalities/41IntAlg_04_LinearIneq.pg b/OpenProblemLibrary/CollegeOfIdaho/setAlgebra_04_01_LinearInequalities/41IntAlg_04_LinearIneq.pg index 72689ed3a6..9d0fbd40ab 100644 --- a/OpenProblemLibrary/CollegeOfIdaho/setAlgebra_04_01_LinearInequalities/41IntAlg_04_LinearIneq.pg +++ b/OpenProblemLibrary/CollegeOfIdaho/setAlgebra_04_01_LinearInequalities/41IntAlg_04_LinearIneq.pg @@ -18,9 +18,7 @@ ## Problem1('') ## KEYWORDS('inequalities') -# Updated by Peter Staab (Fitchburg State) on 2024.01.22 - -DOCUMENT(); # This should be the first executable line in the problem. +DOCUMENT(); # This should be the first executable line in the problem. loadMacros('PGstandard.pl', 'PGML.pl', 'PGtikz.pl', 'PGcourse.pl'); @@ -28,14 +26,14 @@ loadMacros('PGstandard.pl', 'PGML.pl', 'PGtikz.pl', 'PGcourse.pl'); Context("Interval"); -$a = random(-5,1); -$b = $a + random(1,4); -$r1 = random(0,1); -$left = $r1 ? '[' : '('; +$a = random(-5, 1); +$b = $a + random(1, 4); +$r1 = random(0, 1); +$left = $r1 ? '[' : '('; $left_sym = ($r1 ? '\fill' : '\draw') . "[blue]($a,0) circle[radius=3pt];"; -$r2 = random(0,1); -$right = $r2 ? ']' : ')'; +$r2 = random(0, 1); +$right = $r2 ? ']' : ')'; $right_sym = ($r2 ? '\fill' : '\draw') . "[blue]($b,0) circle[radius=3pt];"; $sol = Interval("$left$a,$b$right"); @@ -57,10 +55,14 @@ $right_sym; \foreach \x in {-5,-4,...,1,1,2,...,5} \draw (\x,0.2) -- (\x,-0.2) node [scale=1.5, below] {\(\x\)}; END_TIKZ -$alt_text = "A graph of just the x-axis with a line segment from ($a,0) to ($b,0). " - . "At the left end is an " . ($r1 ? 'closed' : 'open') . ' circle. ' - . "At the right end is an " . ($r2 ? 'closed' : 'open') . ' circle.'; - +$alt_text = + "A graph of just the x-axis with a line segment from ($a,0) to ($b,0). " + . "At the left end is an " + . ($r1 ? 'closed' : 'open') + . ' circle. ' + . "At the right end is an " + . ($r2 ? 'closed' : 'open') + . ' circle.'; BEGIN_PGML >> [! [$alt_text] !]{$graph}{400} << @@ -69,4 +71,11 @@ Express the inequality shown in the graph above using interval notation. Answer: [_]{$sol} END_PGML -ENDDOCUMENT(); \ No newline at end of file + +BEGIN_PGML_SOLUTION +Note that the left endpoint is [@ $r1 ? 'closed' : 'open' @] and +the right endpoint is [@ $r2 ? 'closed' : 'open' @]. +Therefore the interval is from [$a] ([@ $r1 ? 'inclusive' : 'exclusive' @]) +to [$b] ([@ $r2 ? 'inclusive' : 'exclusive' @]). The interval is [`[$sol]`]. +END_PGML_SOLUTION +ENDDOCUMENT(); diff --git a/OpenProblemLibrary/CollegeOfIdaho/setAlgebra_04_01_LinearInequalities/41IntAlg_05_LinearIneq.pg b/OpenProblemLibrary/CollegeOfIdaho/setAlgebra_04_01_LinearInequalities/41IntAlg_05_LinearIneq.pg index 41cee10457..dd78602705 100644 --- a/OpenProblemLibrary/CollegeOfIdaho/setAlgebra_04_01_LinearInequalities/41IntAlg_05_LinearIneq.pg +++ b/OpenProblemLibrary/CollegeOfIdaho/setAlgebra_04_01_LinearInequalities/41IntAlg_05_LinearIneq.pg @@ -29,7 +29,8 @@ loadMacros( Context('Inequalities-AllowStrings'); $a = random(-10, 10, 1); -$ans = Interval("(-inf,$a)")->cmp->withPostFilter(AnswerHints( +$ans = Interval("(-inf,$a)"); +$cmp = $ans->cmp->withPostFilter(AnswerHints( sub { my ($correct, $student, $ans) = @_; return $student =~ /[=><]/; @@ -43,7 +44,11 @@ $ans = Interval("(-inf,$a)")->cmp->withPostFilter(AnswerHints( BEGIN_PGML Express the inequality using interval notation. [``` x<[$a] ```] -Answer: [_]{$ans} +Answer: [_]{$cmp} END_PGML +BEGIN_PGML_SOLUTION +If you need to, draw a number line and note that all values from [` -\infty `] to [`[$a]`], but not including it, therefore the interval should be [`[$ans]`]. +END_PGML_SOLUTION + ENDDOCUMENT(); diff --git a/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_07_pictDistnsWGraphs.pg b/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_07_pictDistnsWGraphs.pg index b88bfea8b8..1c258d971c 100644 --- a/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_07_pictDistnsWGraphs.pg +++ b/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_07_pictDistnsWGraphs.pg @@ -17,26 +17,27 @@ DOCUMENT(); loadMacros( - 'PGstandard.pl', 'PGML.pl', 'contextPercent.pl', - + 'PGstandard.pl', 'PGML.pl', 'contextPercent.pl', + 'PGtikz.pl', 'parserPopUp.pl', 'PGstatisticsmacros.pl', 'PGcourse.pl' ); # generate some data is is skewed rigt -@cutoffs = (59, 62, 65, 68, 71, 74, 77, 80); +@cutoffs = (59, 62, 65, 68, 71, 74, 77, 80); do { -@norm_rands = urand(70, 5, 40, 1); -@h = (); -$max = 0; -for $i (0 .. $#cutoffs - 1) { - $h[$i] = scalar(grep { $_ >= $cutoffs[$i] && $_ < $cutoffs[ $i + 1 ] } - @norm_rands); - $max = $h[$i] if $h[$i]> $max; -} - -} until $max <=10; + @norm_rands = urand(70, 5, 40, 1); + @h = (); + $max = 0; + for $i (0 .. $#cutoffs - 1) { + $h[$i] = + scalar(grep { $_ >= $cutoffs[$i] && $_ < $cutoffs[ $i + 1 ] } + @norm_rands); + $max = $h[$i] if $h[$i] > $max; + } + +} until $max <= 10; $num_students = 0; $num_students += $h[$_] for (0 .. $#h); @@ -49,7 +50,7 @@ for $i (0 .. $#h) { } $xticks = join(', ', @cutoffs); -$graph = createTikZImage(); +$graph = createTikZImage(); $graph->tikzLibraries('arrows.meta'); $graph->BEGIN_TIKZ \tikzset{>={Stealth[scale=1.5]},xscale=0.5} @@ -66,18 +67,23 @@ $rects; \foreach \y in {5,10} \draw (0,{\y}) -- (-0.5,{\y}) node [left] {\y}; END_TIKZ -$alt_text = "A histogram of the $num_students students. The cutoff values are " - . join(', ', @cutoffs) . ' and there are 7 bars. From left to right the ' - . "heights are " . join(', ', @h) . '.'; - +$alt_text = + "A histogram of the $num_students students. The cutoff values are " + . join(', ', @cutoffs) + . ' and there are 7 bars. From left to right the ' + . "heights are " + . join(', ', @h) . '.'; + Context('Percent'); -$k = random(0,4); +$k = random(0, 4); -$inter = Percent(($h[$k]+$h[$k+1])/$num_students); -$dd = DropDown(['59-65','62-68','65-71','68-74','71-77','74-80'],$k); +# number of students in a random interval +$stud = $h[$k] + $h[ $k + 1 ]; +$inter = Percent($stud / $num_students); +$dd = DropDown([ '59-65', '62-68', '65-71', '68-74', '71-77', '74-80' ], $k); -$over74 = Percent(($h[5]+$h[6])/$num_students); +$over74 = Percent(($h[5] + $h[6]) / $num_students); BEGIN_PGML The histogram below shows the heights of [$num_students] students. @@ -93,4 +99,15 @@ c) Which interval is about [$inter] perecent of the students. [_]{$dd} Note: on b) include the % sign. END_PGML +BEGIN_PGML_SOLUTION + +a) This is interpreting the height of the bar between 65 and 68, which is [$h[2]]. + +b) The height of the bars that are greater than 74 is [$h[5]]+[$h[6]]=[$h[5]+$h[6]], so the percent is [` \frac{[$h[5]+$h[6]]}{[$num_students]} = [$over74].`] + +c) Note that [$inter] percent of the students is [`[$inter] \cdot +[$num_students] = [$stud]`]. Of the possible intervals, the only result is [$dd]. + +END_PGML_SOLUTION + ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_08_PictDistnsWGraphs.pg b/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_08_PictDistnsWGraphs.pg index 67547eb1b7..5eb7d96cd8 100644 --- a/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_08_PictDistnsWGraphs.pg +++ b/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch01PicturingDistributionsWithGraphs/01Stats_08_PictDistnsWGraphs.pg @@ -9,11 +9,8 @@ ## AuthorText1('David Moore') ## EditionText1('5e') ## Section1('1') -## Problem1('') ## KEYWORDS('statistics', 'quantitative data', 'categorical data', 'histogram') -# Updated by Peter Staab (Fitchburg State) on 2024.01.22 - DOCUMENT(); loadMacros( diff --git a/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch02DescribingData/02Stats_01_DescrData.pg b/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch02DescribingData/02Stats_01_DescrData.pg index debad1bdac..3f349bd102 100644 --- a/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch02DescribingData/02Stats_01_DescrData.pg +++ b/OpenProblemLibrary/CollegeOfIdaho/setStatistics_Ch02DescribingData/02Stats_01_DescrData.pg @@ -57,9 +57,8 @@ $rects; \foreach \y in {5,10,15,20} \draw (0.5,\y) -- (0.3,\y) node [scale=2, left] {\y}; END_TIKZ -$skew = DropDown([ 'right', 'symmetric', 'left' ], $s); -$middle = DropDown([ 'mean', 'about equal', 'median' ], $s); - +$skew = DropDown([ 'right', 'symmetric', 'left' ], $s); +$middle = DropDown([ 'mean', 'about equal', 'median' ], $s); BEGIN_PGML Consider the histogram shown below. @@ -72,12 +71,12 @@ b) Which is bigger for this data set, the mean or the median, or are they about END_PGML -if ($s==0) { +if ($s == 0) { BEGIN_PGML_SOLUTION In this case, since there is a peak to the left and a tail on the right, this is skewed to the right. The mean is closer to the peak and the median (middle of the data) is to the right of the mean, so the median is larger. END_PGML_SOLUTION -} elsif ($s ==1) { +} elsif ($s == 1) { BEGIN_PGML_SOLUTION In this case, the histogram appears relatively symmetric (though not perfect). Because it is symmetric, the mean and median is about equal. diff --git a/OpenProblemLibrary/Rochester/setProbability7RandomVariables/p1.pg b/OpenProblemLibrary/Rochester/setProbability7RandomVariables/p1.pg index 064236ea29..1cf36f9889 100644 --- a/OpenProblemLibrary/Rochester/setProbability7RandomVariables/p1.pg +++ b/OpenProblemLibrary/Rochester/setProbability7RandomVariables/p1.pg @@ -14,10 +14,7 @@ DOCUMENT(); # This should be the first executable line in the problem. -loadMacros( - 'PGstandard.pl', 'PGML.pl', 'niceTables.pl', 'parserPopUp.pl', - 'PGcourse.pl' -); +loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); $showPartialCorrectAnswers = 0; @@ -25,7 +22,7 @@ $showPartialCorrectAnswers = 0; $b1[3] = 1 - $b1[0] - $b1[1] - $b1[2]; @b2 = (random(0, .3, .1), random(.1, .3, .1), random(-0.3, -0.1, .1)); -$b2[3] = 1 - $b1 - $b2 - $b3; +$b2[3] = 1 - $b2[0] - $b2[1] - $b2[2]; @b2 = random_subset(4, @b2); do { @@ -34,63 +31,54 @@ do { $sum += $_ for (@b3); } until $sum != 1; -@tables = ( - DataTable( - [ - [ 'Event', '\(e_1\)', '\(e_2\)', '\(e_3\)', '\(e_4\)' ], - [ 'Probability', @b1 ], - ], - align => '|c|r|r|r|r|', - horizontalrules => 1 - ), - DataTable( - [ - [ 'Event', '\(e_1\)', '\(e_2\)', '\(e_3\)', '\(e_4\)' ], - [ 'Probability', @b2 ], - ], - align => '|c|r|r|r|r|', - horizontalrules => 1 - ), - DataTable( - [ - [ 'Event', '\(e_1\)', '\(e_2\)', '\(e_3\)', '\(e_4\)' ], - [ 'Probability', @b3 ], - ], - align => '|c|r|r|r|r|', - horizontalrules => 1 - ) -); - @dropdowns = ( DropDown([ 'Valid', 'Invalid' ], 0), DropDown([ 'Valid', 'Invalid' ], 1), DropDown([ 'Valid', 'Invalid' ], 1) ); -@opts = random_subset(3,0..2); +@opts = random_subset(3, 0 .. 2); BEGIN_PGML Determine whether the following are valid probability models or not. Determine if each is a valid or invalid probability model. a) Table 1 - [$tables[$opts[0]]]* + [# [.Event.][.[`e_1`].] [. [`e_2`].] [.[`e_3`].] [. [`e_4`].]* + [. Probability .] [. [$b1[0]] .][. [$b1[1]] .][. [$b1[2]] .][. [$b1[3]] .]* + #]{horizontalrules => 1} Answer: [_]{$dropdowns[$opts[0]]} b) Table 2 - [$tables[$opts[1]]]* + [# [.Event.][.[`e_1`].] [. [`e_2`].] [.[`e_3`].] [. [`e_4`].]* + [. Probability .] [. [$b2[0]] .][. [$b2[1]] .][. [$b2[2]] .][. [$b2[3]] .]* + #]{horizontalrules => 1} + Answer: [_]{$dropdowns[$opts[1]]} c) Table 3 - [$tables[$opts[2]]]* + [# [.Event.][.[`e_1`].] [. [`e_2`].] [.[`e_3`].] [. [`e_4`].]* + [. Probability .] [. [$b3[0]] .][. [$b3[1]] .][. [$b3[2]] .][. [$b3[3]] .]* + #]{horizontalrules => 1} + Answer: [_]{$dropdowns[$opts[2]]} END_PGML +BEGIN_PGML_SOLUTION +Recall that for a discrete probability distriubution, all probability values [` p_i `] must satisfy [` 0 \leq p_i \leq 1 `] and [` p_1 + p_2 + \cdots + p_n = 1 `]. + +a) This satsifies both conditions. + +b) One of the values is less than 0, so this is not valid. + +c) The sum of the probabilities is not 1, so this is not valid. +END_PGML_SOLUTION + ENDDOCUMENT(); # This should be the last executable line in the problem. diff --git a/OpenProblemLibrary/Rochester/setProbability7RandomVariables/ur_pb_7_3.pg b/OpenProblemLibrary/Rochester/setProbability7RandomVariables/ur_pb_7_3.pg index 7f2e36992a..276fca7627 100644 --- a/OpenProblemLibrary/Rochester/setProbability7RandomVariables/ur_pb_7_3.pg +++ b/OpenProblemLibrary/Rochester/setProbability7RandomVariables/ur_pb_7_3.pg @@ -15,7 +15,7 @@ DOCUMENT(); -loadMacros('PGstandard.pl', 'PGML.pl', 'niceTables.pl', 'PGcourse.pl'); +loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl'); $a1 = random(1, 20); @a = ('X', $a1 .. $a1 + 4); @@ -24,17 +24,12 @@ do { @p = ('P(X)', map { random(.1, .3, .1) } (1 .. 3), 0.1); $p[5] = 1 - $p[1] - $p[2] - $p[3] - $p[4]; } until $p[2] != $p[3]; -# warn pretty_print(~~@p); @event = ( - "P(x=$a[3])", - "P(x>$a[3])", - "P(x\ge $a[2])", - "P(x\le $a[4])", - "P(x\ge $a[4] \mbox{ or } x<$a[2])", - "P(x<$a[5])", - "P(x=$a[1])", - "P($a[1]\le x <$a[3])" + "P(x=$a[3])", "P(x>$a[3])", + "P(x\ge $a[2])", "P(x\le $a[4])", + "P(x\ge $a[4] \mbox{ or } x<$a[2])", "P(x<$a[5])", + "P(x=$a[1])", "P($a[1]\le x <$a[3])" ); @ans = ( @@ -44,8 +39,7 @@ do { 1 - $p[5], $p[1] + $p[4] + $p[5], 1 - $p[5], - $p[1], - $p[1] + $p[2] + $p[1], $p[1] + $p[2] ); @slice = random_subset(3, 0 .. $#event); @@ -70,4 +64,32 @@ c) [`[$event[$slice[2]]] =`] [_]{$ans[$slice[2]]} END_PGML -ENDDOCUMENT(); # This should be the last executable line in the problem. +@explanations = ( + "Since this is just the value \(X=$a[3]\), this is just " + . "\(P(X =$a[3]) = $ans[0]\)", + "For \(P(x>$a[3])\), sum the values in the table for \( x > $a[3]\) and " + . "the result is $ans[1]", + "For \(P(x\ge $a[2])\), sum the values in the table and the result is $ans[2]", + "For \(P(x\le $a[4])\), sum the values in the table and the result is $ans[3]", + "For \(P(x\ge $a[4] \mbox{ or } x<$a[2])\), sum the values in the table " + . "greater than or equal to $a[4] and less than $a[2] and the result is " + . "$ans[4]", + "For \(P(x<$a[5]])\), sum the values in the table for \( x < $a[5]\) and " + . "the result is $ans[5]", + "Since this is just the value \(X=$a[1]\), this is just " + . "\(P(X =$a[1]) = $ans[6]\)", + "For \(P($a[1]\le x <$a[3]\), sum the values for $a[1] and $a[2] in the table. " + . "The result is $ans[7]." +); + +BEGIN_PGML_SOLUTION +For each of these, sum the values for the given probability. + +a) [$explanations[$slice[0]]]* + +d) [$explanations[$slice[1]]]* + +c) [$explanations[$slice[2]]]* +END_PGML_SOLUTION + +ENDDOCUMENT(); # This should be the last executable line in the problem. \ No newline at end of file diff --git a/OpenProblemLibrary/Rochester/setStatistics2Measures/ur_stt_2_4.pg b/OpenProblemLibrary/Rochester/setStatistics2Measures/ur_stt_2_4.pg index dd547b0cf8..1d1df75fdf 100644 --- a/OpenProblemLibrary/Rochester/setStatistics2Measures/ur_stt_2_4.pg +++ b/OpenProblemLibrary/Rochester/setStatistics2Measures/ur_stt_2_4.pg @@ -16,8 +16,6 @@ ## Problem1('7') ## KEYWORDS('Measure', 'Mean', 'Median', 'Skew','statistics','measures','mean','median') -# Updated by Peter Staab (Fitchburg State) on 2024.01.22 - DOCUMENT(); loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); @@ -26,10 +24,10 @@ loadMacros('PGstandard.pl', 'PGML.pl', 'parserPopUp.pl', 'PGcourse.pl'); $median = random(70, 85, 1); # Total number of points will be 2n+1 and add n points above and below the median. -$n = random(4, 6); -@pts = ($median); -for (1..4) { - push(@pts, random($median - 10, $median), random($median, $median+10)); +$n = random(4, 6); +@pts = ($median); +for (1 .. 4) { + push(@pts, random($median - 10, $median), random($median, $median + 10)); } @pts = random_subset(scalar(@pts), @pts);