Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replaced probability_1 with new probability of one event exercise

Reviewers: eater, emily

Reviewed By: eater

Differential Revision: http://phabricator.khanacademy.org/D446
  • Loading branch information...
commit a8d7eb110e3e724f5d30441c2024a41b984b0afc 1 parent f0e8e5a
@mwittels mwittels authored
Showing with 64 additions and 107 deletions.
  1. +56 −107 exercises/probability_1.html
  2. +8 −0 utils/math.js
View
163 exercises/probability_1.html
@@ -2,29 +2,29 @@
<html data-require="math math-format probability word-problems">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>Probability 1</title>
+ <title>Probability of One Event</title>
<script src="../khan-exercise.js"></script>
</head>
<body>
<div class="exercise">
<div class="problems">
- <div>
+ <div id="marbles">
<div class="vars">
- <var id="CONTAINER">randFromArray(["bag", "jar", "box", "cup"])</var>
+ <var id="CONTAINER">randFromArray(["bag", "jar", "box", "goblet"])</var>
<var id="MARBLE">randFromArray(["marble", "ball", "jelly bean"])</var>
- <var id="RED">randRange(3, 11)</var>
- <var id="GREEN">randRange(3, 11)</var>
- <var id="BLUE">randRange(3, 11)</var>
- <var id="TOTAL">RED + GREEN + BLUE</var>
+ <var id="REDMAR">randRange(3, 11)</var>
+ <var id="GREENMAR">randRange(3, 11)</var>
+ <var id="BLUEMAR">randRange(3, 11)</var>
+ <var id="TOTAL">REDMAR + GREENMAR + BLUEMAR</var>
<var id="NOT">rand(2) === 0</var>
- <var id="CHOSEN_COLOR, CHOSEN_NUMBER">randFromArray([["red", RED], ["green", GREEN], ["blue", BLUE]])</var>
+ <var id="CHOSEN_COLOR, CHOSEN_NUMBER">randFromArray([["red", REDMAR], ["green", GREENMAR], ["blue", BLUEMAR]])</var>
<var id="NUMBER">NOT ? TOTAL - CHOSEN_NUMBER : CHOSEN_NUMBER</var>
</div>
<div class="question">
- <p>A <var>CONTAINER</var> contains <code><var>RED</var></code> red <var>MARBLE</var>s,
- <code><var>GREEN</var></code> green <var>MARBLE</var>s, and <code><var>BLUE</var></code> blue <var>MARBLE</var>s.</p>
+ <p>A <var>CONTAINER</var> contains <code><var>REDMAR</var></code> red <var>MARBLE</var>s,
+ <code><var>GREENMAR</var></code> green <var>MARBLE</var>s, and <code><var>BLUEMAR</var></code> blue <var>MARBLE</var>s.</p>
<p>If a <var>MARBLE</var> is randomly chosen, what is the probability
that it is <em data-if="NOT">not</em> <var>CHOSEN_COLOR</var>? Write your answer as a simplified fraction.</p>
@@ -32,14 +32,14 @@
<div class="solution"><var>NUMBER / TOTAL</var></div>
<div class="hints">
- <p>There are <code><var>RED</var> + <var>GREEN</var> + <var>BLUE</var> = <var>TOTAL</var></code> <var>MARBLE</var>s in the <var>CONTAINER</var>.</p>
+ <p>There are <code><var>REDMAR</var> + <var>GREENMAR</var> + <var>BLUEMAR</var> = <var>TOTAL</var></code> <var>MARBLE</var>s in the <var>CONTAINER</var>.</p>
<p>There are <code><var>CHOSEN_NUMBER</var></code> <var>CHOSEN_COLOR</var> <var>MARBLE</var>s.
<span data-if="NOT">That means <code><var>TOTAL</var> - <var>CHOSEN_NUMBER</var> = <var>NUMBER</var></code> are <em>not</em> <var>CHOSEN_COLOR</var>.</span></p>
<p>The probability is <code>\displaystyle <var>fractionSimplification(NUMBER, TOTAL)</var></code>.</p>
</div>
</div>
- <div>
+ <div id="die">
<div class="vars">
<var id="RESULT_DESC, RESULT_POSSIBLE">randFromArray([
["a 1", [1]],
@@ -81,105 +81,54 @@
</div>
</div>
- <div>
+ <div id="circles">
<div class="vars">
- <var id="REPS, DESC, WANTED">randFromArray([
- [3, "no heads", [0]],
- [3, "heads exactly once", [1]],
- [3, "heads exactly twice", [2]],
- [3, "heads at least once", [1, 2, 3]],
- [3, "heads at least twice", [2, 3]],
- [3, "heads every time", [3]],
- [4, "no heads", [0]],
- [4, "heads exactly once", [1]],
- [4, "heads exactly twice", [2]],
- [4, "exactly three heads", [3]],
- [4, "heads at least once", [1, 2, 3, 4]],
- [4, "heads at least twice", [2, 3, 4]],
- [4, "at least three heads", [3, 4]],
- [4, "heads every time", [4]],
-
- [3, "no tails", [3]],
- [3, "tails exactly once", [2]],
- [3, "tails exactly twice", [1]],
- [3, "tails at least once", [0, 1, 2]],
- [3, "tails at least twice", [0, 1]],
- [3, "tails every time", [0]],
- [4, "no tails", [4]],
- [4, "tails exactly once", [3]],
- [4, "tails exactly twice", [2]],
- [4, "exactly three tails", [1]],
- [4, "tails at least once", [0, 1, 2, 3]],
- [4, "tails at least twice", [0, 1, 2]],
- [4, "at least three tails", [0, 1]],
- [4, "tails every time", [0]]
- ])</var>
-
- <var id="ALL">coinFlips(REPS)</var>
- <var id="ALL_SEQS">(function() {
- return $.map(ALL, function( el, i ) {
- return el[0];
- });
- })()</var>
- <var id="WANTED_LIST">(function() {
- return $.map($.grep(ALL, function( el, i ) {
- return WANTED.indexOf(el[1]) !== -1;
- }), function( el, i ) {
- return el[0];
- });
- })()</var>
- <var id="WANTED_COUNT">choose(REPS, WANTED)</var>
- <var id="TWO_TO_REPS">pow(2, REPS)</var>
- </div>
-
- <div class="question">
- <p>A fair coin is flipped <var>REPS === 3 ? "three" : "four"</var> times. What is the
- probability of getting <var>DESC</var>? Write your answer as a simplified fraction.</p>
+ <var id="BIG_RAD">randRange(7,12)</var>
+ <var id="SMALL_RAD">randRange(3,6)</var>
+ <var id="BIG_GIVEN">randFromArray(["radius","diameter","circumference"])</var>
+ <var id="SMALL_GIVEN">randFromArray(["radius","diameter","circumference"])</var>
+ <var id="BIG_INFO">BIG_GIVEN === "radius" ? BIG_RAD : BIG_RAD*2</var>
+ <var id="SMALL_INFO">SMALL_GIVEN === "radius" ? SMALL_RAD : SMALL_RAD*2</var>
+ <var id="GCD">getGCD(Math.pow(SMALL_RAD,2),Math.pow(BIG_RAD,2))</var>
</div>
-
- <div class="solution"><var>WANTED_COUNT / TWO_TO_REPS</var></div>
-
- <div class="hints">
- <p>There are <code><var>(new Array(REPS)).join("2 \\cdot ")</var>2 = 2^{<var>REPS</var>} = <var>TWO_TO_REPS</var></code> possibilities for the sequence of flips.</p>
- <p>The possibilities are <var>toSentence(ALL_SEQS)</var>.</p>
- <p>There <var>WANTED_COUNT === 1 ? "is only" : "are"</var> <var>plural(WANTED_COUNT, "favorable outcome")</var>: <var>toSentence(WANTED_LIST)</var>.</p>
- <p>The probability is <code>\displaystyle <var>fractionSimplification(WANTED_COUNT, TWO_TO_REPS)</var></code>.</p>
- </div>
- </div>
-
- <div>
- <div class="vars">
- <var id="LOW, HIGH">randFromArray([ [1, 10], [11, 20], [21, 30], [31, 40], [41, 50], [51, 60], [61, 70], [71, 80], [81, 90], [91, 100] ])</var>
- <var id="POSSIBLE">(function() {
- var list = [];
- for (var i = LOW; i &lt;= HIGH; i++) {
- list.push(i);
- }
- return list;
- })()</var>
-
- <var id="COND_DESC, COND_FN">randFromArray([
- ["prime", KhanUtil.isPrime],
- ["divisible by both 2 and 3", function(n) { return n % 6 &lt;= 0.5; }],
- ["divisible by either 3 or 5", function(n) { return n % 3 &lt;= 0.5 || n % 5 &lt;= 0.5; }],
- ["divisible by either 4 or 7", function(n) { return n % 4 &lt;= 0.5 || n % 7 &lt;= 0.5; }]
- ])</var>
-
- <var id="WANTED_LIST">$.grep(POSSIBLE, COND_FN)</var>
- <var id="WANTED_COUNT">WANTED_LIST.length</var>
- </div>
-
- <div class="question">
- <p>A positive integer is picked randomly from <var>LOW</var> to <var>HIGH</var>, inclusive.</p>
- <p>What is the probability that it is <strong><var>COND_DESC</var></strong>? Write your answer as a simplified fraction.</p>
- </div>
-
- <div class="solution"><var>WANTED_COUNT / POSSIBLE.length</var></div>
+ <p>
+ You throw a dart at a circular dartboard with <var>BIG_GIVEN</var> <var>BIG_INFO</var>
+ <code><var>BIG_GIVEN === "circumference" ? "\\pi" : ""</var></code>. Inside the dartboard is a circular target with
+ <var>SMALL_GIVEN</var> <var>SMALL_INFO</var> <code><var>SMALL_GIVEN === "circumference" ? "\\pi" : ""</var></code>.
+ Assume you're good enough to hit the dartboard every time, and you'll hit every point on the dartboard with equal probability.
+ </p>
+ <p class="question">
+ What is the probability that you will hit the target?
+ </p>
+
+ <div class="solution" data-forms="proper, decimal"><var>Math.pow(SMALL_RAD,2)/Math.pow(BIG_RAD,2)</var></div>
<div class="hints">
- <p>There are <var>POSSIBLE.length</var> possibilities for the chosen number.<br>The possibilities are <var>toSentence(POSSIBLE)</var>.</p>
- <p>There <var>WANTED_COUNT === 1 ? "is only" : "are"</var> <var>plural(WANTED_COUNT, "favorable outcome")</var>: <var>toSentence(WANTED_LIST)</var>.</p>
- <p>The probability is <code>\displaystyle <var>fractionSimplification(WANTED_COUNT, POSSIBLE.length)</var></code>.</p>
+ <p>
+ Since you're equally likely to hit every point on the dartboard, the probability that you hit the target is basically
+ the size of the target divided by the size of the dartboard.
+ </p>
+ <p>
+ To figure out these sizes, we need to figure out the areas of the target and the dartboard.
+ </p>
+ <p>
+ The area of the dartboard is <code>\pi r^2</code>, so since <code><var>BIG_GIVEN === "radius" ? "radius =" + BIG_INFO :
+ (BIG_GIVEN === "diameter" ? "radius = \\frac{diameter}{2}" : "radius = \\frac{circumference}{2 \\pi}")</var></code>,
+ the area of the dartboard is <code><var>BIG_RAD</var>^2 \pi</code>.
+ </p>
+ <p>
+ The area of the target is <code>\pi r^2</code>, so since <code><var>SMALL_GIVEN === "radius" ? "radius =" + SMALL_INFO :
+ (SMALL_GIVEN === "diameter" ? "radius = \\frac{diameter}{2}" : "radius = \\frac{circumference}{2 \\pi}")</var></code>,
+ the area of the target is <code><var>SMALL_RAD</var>^2 \pi</code>.
+ </p>
+ <p data-if="GCD != 1">
+ So, the probability that you will hit the target is <code> \frac{<var>Math.pow(SMALL_RAD,2)</var>}{<var>Math.pow(BIG_RAD,2)</var>}
+ = \frac{<var>Math.pow(SMALL_RAD,2)/GCD</var>}{<var>Math.pow(BIG_RAD,2)/GCD</var>}</code>.
+ </p>
+ <p data-else>
+ So, the probability that you will hit the target is <code> \frac{<var>Math.pow(SMALL_RAD,2)</var>}{<var>Math.pow(BIG_RAD,2)</var>}
+ </code>.
+ </p>
</div>
</div>
</div>
View
8 utils/math.js
@@ -78,6 +78,14 @@ $.extend(KhanUtil, {
return Math.floor(x + 0.001);
},
+ factorial: function(x) {
+ if (x <= 1) {
+ return x;
+ } else {
+ return x * KhanUtil.factorial(x-1);
+ }
+ },
+
getGCD: function(a, b) {
if (arguments.length > 2) {
var rest = [].slice.call(arguments, 1);
Please sign in to comment.
Something went wrong with that request. Please try again.