Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 143 lines (115 sloc) 6.318 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
<!DOCTYPE html>
<html data-require="math">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Dependent probability</title>
<script src="../khan-exercise.js"></script>

<style>
.fair {
color: #33cc33;
}

.unfair {
color: #cc3333;
}
</style>
</head>
<body>
<div class="exercise">
<div class="vars" data-ensure="PERCENT_CHANCE_UNFAIR_HEADS !== 50">
<!-- CONSTANTS -->
<!-- random range for % chance heads shows on the unfair coin -->
<var id="PERCENT_UNFAIR_HEADS_MIN">30</var>
<var id="PERCENT_UNFAIR_HEADS_MAX">70</var>

<!-- increment of selected random value (i.e. 20, 25, 30, 35... are possible values for incr of 5 -->
<var id="PERCENT_UNFAIR_HEADS_INCR">5</var>


<!-- PROBLEM-SPECIFIC VALUES -->
<!-- random range for total coins in bag -->
<var id="NUM_COINS">randRange(5, 15)</var>

<!-- random range for unfair coins -->
<!-- NOTE: MAX must be <= COINS_MIN -->
<var id="NUM_UNFAIR_COINS">randRange(2, 4)</var>

<var id="NUM_INCR">(PERCENT_UNFAIR_HEADS_MAX - PERCENT_UNFAIR_HEADS_MIN) / PERCENT_UNFAIR_HEADS_INCR</var>

<var id="PERCENT_CHANCE_UNFAIR_HEADS">PERCENT_UNFAIR_HEADS_MIN + rand(NUM_INCR + 1) * PERCENT_UNFAIR_HEADS_INCR</var>

<!-- random range for number of coin flips -->
<var id="NUM_FLIPS">randRange(2, 4)</var>

<var id="UNFAIR_COIN_FRACTION_STRING">"\\frac{" + NUM_UNFAIR_COINS + "}{" + NUM_COINS + "}"</var>

<!-- create some convenience variables for forming the hint text -->
<var id="UNFAIR_COIN_FRACTION_STRING">"\\frac{" + NUM_UNFAIR_COINS + "}{" + NUM_COINS + "}"</var>
<var id="FAIR_COIN_FRACTION_STRING">"\\frac{" + (NUM_COINS-NUM_UNFAIR_COINS) + "}{" + NUM_COINS + "}"</var>
<var id="DECIMAL_CHANCE_UNFAIR_HEADS">PERCENT_CHANCE_UNFAIR_HEADS / 100</var>
<var id="UNFAIR_HEADS_DECIMAL_FORMULA">
(function() {
var uhdf = DECIMAL_CHANCE_UNFAIR_HEADS.toString();
for (var i = 0; i &lt; NUM_FLIPS - 1; i++) {
uhdf += " \\times " + DECIMAL_CHANCE_UNFAIR_HEADS;
}
return uhdf;
})()
</var>
<var id="UNFAIR_HEADS_PERCENT_FORMULA">
(function() {
var uhpf = PERCENT_CHANCE_UNFAIR_HEADS + "\\%";
for (var i = 0; i &lt; NUM_FLIPS - 1; i++) {
uhpf += " \\times " + PERCENT_CHANCE_UNFAIR_HEADS + "\\%";
}
return uhpf;
})()
</var>
<var id="DECIMAL_CHANCE_FAIR_HEADS">0.5</var>
<var id="FAIR_HEADS_DECIMAL_FORMULA">
(function() {
var fhdf = DECIMAL_CHANCE_FAIR_HEADS.toString();
for (var i = 0; i &lt; NUM_FLIPS - 1; i++) {
fhdf += " \\times " + DECIMAL_CHANCE_FAIR_HEADS;
}
return fhdf;
})()
</var>

<!-- For answer computing -->
<var id="CHANCE_UNFAIR_PICKED">NUM_UNFAIR_COINS / NUM_COINS</var>
<var id="CHANCE_FAIR_PICKED">1 - CHANCE_UNFAIR_PICKED</var>

<var id="ANSWER">round(10000 * (CHANCE_UNFAIR_PICKED * pow((PERCENT_CHANCE_UNFAIR_HEADS / 100), NUM_FLIPS) +
CHANCE_FAIR_PICKED * pow(0.5,NUM_FLIPS))) / 100</var>

</div>

<div class="problems">
<div>
<p class="problem">You have <code><var>NUM_COINS</var></code> coins in a bag. <code><var>NUM_UNFAIR_COINS</var></code> of them are unfair in that they have a <code><var>PERCENT_CHANCE_UNFAIR_HEADS</var>\%</code> chance of coming up heads when flipped (the rest are fair coins). You randomly choose one coin from the bag and flip it <code><var>NUM_FLIPS</var></code> times.</p>
<p class="question">What is the probability, written as a percentage, of getting <code><var>NUM_FLIPS</var></code> heads? Round your answer to the nearest hundredth of a percent.</p>
<p class="solution" data-forms="percent" data-max-error="0.01"><var>ANSWER</var></p>
</div>
</div>

<div class="hints">
<!-- hint indicating different coin types -->
<p>You can only pick a fair coin or pick an unfair coin. There is no other outcome.</p>

<!-- hint questioning coin type selection chances -->
<p>What chance do you have of picking an unfair coin? How about a fair coin?</p>

<!-- hint showing chance of unfair coin picked -->
<p>An unfair coin occurs <code class="unfair"><var>UNFAIR_COIN_FRACTION_STRING</var></code> of the time.</p>

<!-- hint showing chance of fair coin picked -->
<p>A fair coin occurs the rest of the time, or <code class="unfair"><var>FAIR_COIN_FRACTION_STRING</var></code> of the time.</p>

<!-- hint questioning head-flipping chances for unfair coin -->
<p>For that <code class="unfair"><var>UNFAIR_COIN_FRACTION_STRING</var></code> of the time that you pick an unfair coin,
what is the chance of flipping <code class="unfair"><var>NUM_FLIPS</var></code> heads using that unfair coin?</p>

<!-- hint showing chance of flipping all heads for unfair coin -->
<p>The chance is <code class="unfair"><var>UNFAIR_HEADS_PERCENT_FORMULA</var></code>, or
<code class="unfair"><var>UNFAIR_HEADS_DECIMAL_FORMULA</var></code>.</p>

<!-- hint suggesting combining unfair coin selection with all-heads-flip event -->
<p>Now, then, your chance of both picking the unfair coin and also flipping
<code class="unfair"><var>NUM_FLIPS</var></code> heads--the chance that both these events occur--is what?</p>

<!-- hint revealing computed chance with unfair coin -->
<p>It is <code class="unfair"><var>UNFAIR_COIN_FRACTION_STRING</var> \times <var>UNFAIR_HEADS_DECIMAL_FORMULA</var></code>.</p>

<!-- hint questioning the fair coin computation -->
<p>Now, the other possibility, picking the fair coin and flipping <code class="fair"><var>NUM_FLIPS</var></code> heads is what?</p>

<!-- hint showing the fair coin computation -->
<p>It is <code class="fair"><var>FAIR_COIN_FRACTION_STRING</var> \times <var>FAIR_HEADS_DECIMAL_FORMULA</var></code>.</p>

<!-- hint questioning how to combine previously computed events -->
<p>How do you combine these two mutually exclusive events to find the chance that either occurs?</p>

<!-- hint revealing the answer -->
<p>Add them! So your answer is
<code class="unfair"><var>UNFAIR_COIN_FRACTION_STRING</var> \times <var>UNFAIR_HEADS_DECIMAL_FORMULA</var></code>+
<code class="fair"><var>FAIR_COIN_FRACTION_STRING</var> \times <var>FAIR_HEADS_DECIMAL_FORMULA</var></code>, or
<code><var>ANSWER</var>\%</code>.</p>
</div>
</div>
</body>
</html>
Something went wrong with that request. Please try again.