Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions Contrib/Fitchburg/Algebra/intervals/graphing-intervals.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
## 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
a) Graph the solution set for the interval [`(-[$x1],[$x1]]`].

[_]{$gt1}

b) Graph the solution set for the linear inequality [`x < [$x2]`].

[_]{$gt2}
END_PGML

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();
90 changes: 90 additions & 0 deletions Contrib/Fitchburg/Probability/contingency_table.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
## 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'
);

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;

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:

[#
[. .] [. 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.

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

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();
25 changes: 18 additions & 7 deletions Contrib/Fitchburg/Probability/cookies.pg
Original file line number Diff line number Diff line change
Expand Up @@ -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();

84 changes: 84 additions & 0 deletions Contrib/Fitchburg/Probability/discrete_pdf.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# DESCRIPTION
# A problem that asks students to ...
#
# Modified for WeBWorK by Michael Stassen mstassen(at)fitchburgstate(dot)edu
# ENDDESCRIPTION

## DBsubject(Probability)
## DBchapter(Random variables)
## DBsection(Discrete: probability mass function)
## KEYWORDS('Discrete Distribution', 'PDF')
## 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 my $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();
57 changes: 45 additions & 12 deletions Contrib/Fitchburg/Probability/ice-cream.pg
Original file line number Diff line number Diff line change
@@ -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).
Expand All @@ -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)

Expand Down Expand Up @@ -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}
Expand All @@ -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();
Loading