# Khan/khan-exercises

Switch branches/tags
Nothing to show
Fetching contributors…
Cannot retrieve contributors at this time
361 lines (308 sloc) 17.4 KB
 Probability space
6 randFromArray([4, 6]) randRange(1, GRID_WIDTH) randRange(1, GRID_HEIGHT) randRange(2, GRID_WIDTH + GRID_HEIGHT) (function() { var pairs = [], i, j; for (i = 1; i <= GRID_WIDTH; i++) { for (j = 1; j <= GRID_HEIGHT; j++) { if (PRED(i, j)) { pairs.push([i, j]); } } } return pairs; })() MATCHING_PAIRS.length GRID_WIDTH * GRID_HEIGHT

You are given two dice to roll. One is black with six sides; the other is white with four sides. You are given two six-sided dice to roll.

If it helps, you may select the matching outcomes below. Your selections aren't checked with your answer:

0 of SOLUTION_D selected
Khan.scratchpad.disable(); // Set .e-grid size. \$('.e-grid').addClass('e-six-by-' + (GRID_HEIGHT === 6 ? 'six' : 'four')); // Toggle cell selection on click. var selected = \$('#e-selected-count'); \$('.e-dice').on('click', function() { \$(this).toggleClass('e-selected'); selected.text(\$('.e-selected').length); }); graph.selectMatching = function(matchingPairs) { \$(".e-dice").removeClass("e-selected"); _.each(matchingPairs, function(match) { \$(".e-dice").eq((match[1] - 1) * 6 + (match[0] - 1)).addClass("e-selected"); }); \$("#e-selected-count").text(\$(".e-selected").length); };
SOLUTION_N / SOLUTION_D

There is one matching outcome.

There are SOLUTION_N matching outcomes.

graph.selectMatching(MATCHING_PAIRS);

The probability is the number of matching outcomes divided by all possible outcomes.

The probability is fraction(SOLUTION_N, SOLUTION_D), which reduces to fractionReduce(SOLUTION_N, SOLUTION_D).

The probability is fractionReduce(SOLUTION_N, SOLUTION_D).

function(x, y) { return (x === X && y === Y || x === Y && y === X); }
For a given roll, what is the probability that the dice display X and Y in any order? For a given roll, what is the probability that the dice display X and Y? For a given roll, what is the probability that the dice both display X?
rand(2) function(x, y) { return x % 2 !== EVEN && y === Y; }
For a given roll, what is the probability that the black die displays an even number and the white die displays Y? For a given roll, what is the probability that the black die displays an odd number and the white die displays Y?

How many matching outcomes are there with an even number on the black die and Y on the white die?

How many matching outcomes are there with an odd number on the black die and Y on the white die?

function(x, y) { return x + y === Z; }
For a given roll, what is the probability that the values of the dice add to Z?

For each value on the black die, is there a value on the white die that adds to Z?

function(x, y) { return x + y <= Z; }
For a given roll, what is the probability that the values of the dice add to Z or less?

Count all outcomes that are less than or equal to Z.

function(x, y) { return x === y; }
For a given roll, what is the probability you roll the same number on each die?
function(x, y) { return x === X && y === Y; }
For a given roll, what is the probability the black die displays X and the white die displays Y?
function(x, y) { return x === X || y === X; }
For a given roll, what is the probability at least one die displays X?

Remember that both dice can be X ("at least one").