randRange(6, 10) randRange(2, TOTAL-2) random() < 0.5 randRange(2, Math.min(ALL ? SPECIAL : TOTAL-SPECIAL,4)) randFromArray( [["will visit Mars", "will not visit Mars", "will visit Mars", "will not visit Mars"], ["have done their homework", "have not done their homework", "has done his homework", "has not done his homework"], ["are secretly robots", "are not secretly robots", "is secretly a robot", "is not secretly a robot"], ["forgot their lunch", "remembered their lunch", "forgot his lunch", "remembered his lunch"], ["are martial arts masters", "are not martial arts masters", "is a martial arts master", "is not a martial arts master"], ["play soccer", "do not play soccer", "plays soccer", "does not play soccer"]]) ALL ? EVENT_PY : EVENT_PN ALL ? EVENT_Y : EVENT_N (function(){ prs = []; _.each(_.range(CHOSEN), function(i) { if(ALL) { num = (SPECIAL - i); den = (TOTAL - i); prs.push([num,den]); } else { num = (TOTAL - SPECIAL - i); den = (TOTAL - i); prs.push([num,den]); } }); return prs; })() _.reduce(PROBS, function(n, frac) { return n * frac[0]; }, 1) _.reduce(PROBS, function(n, frac) { return n * frac[1]; }, 1) getGCD(ANS_N, ANS_D)

In a class of TOTAL, there are SPECIAL students who EVENT_PY.

If the teacher chooses CHOSEN students, what is the probability that ALL ? ((CHOSEN === 2) ? "both" : "all " + cardinalThrough20(CHOSEN)) : ((CHOSEN === 2) ? "neither" : "none of the " + cardinalThrough20(CHOSEN)) of them EVENT_PY?

ANS_N / ANS_D

We can think about this problem as the probability of CHOSEN events happening.

The first event is the teacher choosing one student who EVENT_S. The second event is the teacher choosing another student who EVENT_S, given that the teacher already chose someone who EVENT_S , and so on.

We can think about this problem as the probability of CHOSEN events happening.

The first event is the teacher choosing one student who EVENT_S. The second event is the teacher choosing another student who EVENT_S, given that the teacher already chose someone who EVENT_S .

The probabilty that the teacher will choose someone who EVENT_S is the number of students who EVENT_P divided by the total number of students: \dfrac{PROBS[0][0]} {PROBS[0][1]}.

Once the teacher's chosen one student, there are only TOTAL-1 left.

There's also one fewer student who EVENT_S, since the teacher isn't going to pick the same student twice.

So, the probability that the teacher picks a second student who also EVENT_S is \dfrac{PROBS[1][0]} {PROBS[1][1]}.

The probability of the teacher picking two students who EVENT_P must then be \dfrac{PROBS[0][0]} {PROBS[0][1]} \cdot \dfrac{PROBS[1][0]} {PROBS[1][1]}.

We can continue using the same logic for the rest of the students the teacher picks.

So, the probability of the teacher picking CHOSEN students such that ALL ? ((CHOSEN === 2) ? "both" : "all") : "none" of them EVENT_PY is:

\qquad_.map(PROBS, function(p){ return "\\dfrac{"+p[0]+"}{"+p[1]+"}"; }).join("\\cdot") = \dfrac{ANS_N}{ANS_D} = fractionReduce(ANS_N, ANS_D)

randFromArray(["bag", "jar", "box", "goblet"]) randFromArray(["marble", "ball", "jelly bean"]) randRange(2, 6) randRange(2, 6) randRange(2, 6) REDMAR + GREENMAR + BLUEMAR randFromArray([["red", REDMAR], ["green", GREENMAR], ["blue", BLUEMAR]]) randFromArray([["red", REDMAR], ["green", GREENMAR], ["blue", BLUEMAR]]) COLOR_ONE === COLOR_T ? "another " + COLOR_T : "a " + COLOR_T COLOR_ONE === COLOR_T ? NUM_TWO - 1 : NUM_TWO NUM_ONE * AFTER_NUM TOTAL * (TOTAL - 1)

A CONTAINER contains REDMAR red MARBLEs, GREENMAR green MARBLEs, and BLUEMAR blue MARBLEs.

If we choose a MARBLE, then another MARBLE without putting the first one back in the CONTAINER, what is the probability that the first MARBLE will be COLOR_ONE and the second will be COLOR_TCOLOR_ONE === COLOR_T ? " as well?" : "?"

ANS_N / ANS_D

The probability of event A happening, then event B, is the probability of event A happening times the probability of event B happening given that event A already happened.

In this case, event A is picking a COLOR_ONE MARBLE and leaving it out. Event B is picking COLOR_TWO MARBLE.

Let's take the events one at at time. What is the probability that the first MARBLE chosen will be COLOR_ONE?

There are NUM_ONE COLOR_ONE MARBLEs, and TOTAL total, so the probability we will pick a COLOR_ONE MARBLE is \dfrac{NUM_ONE} {TOTAL}.

After we take out the first MARBLE, we don't put it back in, so there are only TOTAL-1 MARBLEs left.

Also, we've taken out one of the COLOR_ONE MARBLEs, so there are only AFTER_NUM left altogether.

Since the first MARBLE was COLOR_ONE, there are still AFTER_NUM COLOR_T MARBLEs left.

So, the probability of picking COLOR_TWO MARBLE after taking out a COLOR_ONE MARBLE is \dfrac{AFTER_NUM} {TOTAL-1}.

Therefore, the probability of picking a COLOR_ONE MARBLE, then COLOR_TWO MARBLE is \dfrac{NUM_ONE}{TOTAL} \cdot \dfrac{AFTER_NUM}{TOTAL-1} = \dfrac{ANS_N}{ANS_D} = fractionReduce(ANS_N, ANS_D)

random() < 0.5 randRange(1,4) CAPTAIN_NUM + randRange(1,6) CAPTAIN_NUM/CAPTAIN_DEM randRange(1,4) PIRATE_NUM + randRange(4,6) PIRATE_NUM/PIRATE_DEM [getGCD(CAPTAIN_NUM,CAPTAIN_DEM), getGCD(PIRATE_NUM,PIRATE_DEM)] "\\dfrac{" + CAPTAIN_NUM/CGCD + "}{" + CAPTAIN_DEM/CGCD + "}" "\\dfrac{" + (CAPTAIN_DEM/CGCD - CAPTAIN_NUM/CGCD) + "}{" + CAPTAIN_DEM/CGCD + "}" "\\dfrac{" + PIRATE_NUM/PGCD + "}{" + PIRATE_DEM/PGCD + "}" "\\dfrac{" + (PIRATE_DEM/PGCD - PIRATE_NUM/PGCD) + "}{" + PIRATE_DEM/PGCD + "}" randRange(0,2) (function(){ if(C_FIRST) { return ["the Captain hits the pirate ship, but the pirate misses", "the Captain misses the pirate ship, but the pirate hits", "both the Captain and the pirate hit each other's ships"][INDEX]; } else { return ["the pirate misses the Captain's ship, but the Captain hits", "the pirate hits the Captain's ship, but the Captain misses", "both the pirate and the Captain hit each other's ships"][INDEX]; } })() (function(){ if(C_FIRST) { return [[CAPTAIN_NUM, CAPTAIN_DEM], [(CAPTAIN_DEM - CAPTAIN_NUM) * PIRATE_NUM, CAPTAIN_DEM * PIRATE_DEM], [0, 1]][INDEX]; } else { return [[CAPTAIN_NUM * (PIRATE_DEM - PIRATE_NUM), CAPTAIN_DEM * PIRATE_DEM], [PIRATE_NUM, PIRATE_DEM], [0, 1]][INDEX]; } })() ANS_N / ANS_D INDEX === 0 || INDEX === 2 INDEX === 1 || INDEX === 2 [C_FIRST ? (C ? "the Captain hitting the pirate ship" : "the Captain missing the pirate ship") : (P ? "the pirate hitting the Captain's ship" : "the pirate missing the Captain's ship"), C_FIRST ? (C ? C_HIT_PRETTY : C_MISS_PRETTY) : (P ? P_HIT_PRETTY : P_MISS_PRETTY)] (function(){ if(C_FIRST) { if(P && C) { return ["the pirate hitting the Captain's ship", 0]; } else if(P) { return ["the pirate hitting the Captain's ship", P_HIT_PRETTY]; } else if(!P && C) { return ["the pirate missing the Captain's ship", 1]; } else { return ["the pirate missing the Captain's ship", P_MISS_PRETTY]; } } else { if(C && P) { return ["the Captain hitting the pirate ship", 0]; } else if(C) { return ["the Captain hitting the pirate ship", C_HIT_PRETTY]; } else if(!C && P) { return ["the Captain missing the pirate ship", 1]; } else { return ["the Captain missing the pirate ship", C_MISS_PRETTY]; } } })() cardinalThrough20(randRange(2, 5))

Captain person(1) has a ship, the H.M.S Crimson Lynx. The ship is DISTANCE furlongs from the dread pirate person(2) and his merciless band of thieves. The ship is DISTANCE furlongs from the dread pirate person(2) and her merciless band of thieves.

If his ship hasn't already been hit, Captain person(1) has probability C_HIT_PRETTY of hitting the pirate ship. If his ship has been hit, Captain person(1) will always miss.

If her ship hasn't already been hit, Captain person(1) has probability C_HIT_PRETTY of hitting the pirate ship. If her ship has been hit, Captain person(1) will always miss.

If his ship hasn't already been hit, dread pirate person(2) has probability P_HIT_PRETTY of hitting the Captain's ship. If his ship has been hit, dread pirate person(2) will always miss.

If her ship hasn't already been hit, dread pirate person(2) has probability P_HIT_PRETTY of hitting the Captain's ship. If her ship has been hit, dread pirate person(2) will always miss.

If the Captain and the pirate each shoot once, and the Captain shoots first, what is the probability that QUESTION?

If the Captain and the pirate each shoot once, and the pirate shoots first, what is the probability that QUESTION?

ANSWER

The probability of event A happening, then event B, is the probability of event A happening times the probability of event B happening given that event A already happened.

In this case, event A is EV_A and event B is EV_B.

The Captain fires first, so his ship can't be sunk before he fires his cannons. The pirate fires first, so his ship can't be sunk before he fires his cannons.

The Captain fires first, so her ship can't be sunk before she fires her cannons. The pirate fires first, so her ship can't be sunk before she fires her cannons.

So, the probability of EV_A is PR_A.

If the Captain hit the pirate ship, the pirate has no chance of firing back. If the pirate hit the Captain's ship, the Captain has no chance of firing back.

If the Captain missed the pirate ship, the pirate has a normal chance to fire back. If the pirate missed the Captain's ship, the Captain has a normal chance to fire back.

So, the probability of EV_B given EV_A is PR_B.

The probability that QUESTION is then the probability of EV_A times the probability of EV_B given EV_A.

This is PR_A \cdot PR_B = fraction(ANS_N, ANS_D, true, true)