randRange(6, 10) randRange(2, TOTAL-2) random() < 0.5 randRange(2, Math.min(ALL ? SPECIAL : TOTAL-SPECIAL,4)) randFromArray( [["will be eaten by bears", "will not be eaten by bears", "will be eaten by bears", "will not be eaten by bears"], ["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; })() (function(){ n = d = 1; _.each(PROBS, function(frac) { n *= frac; d *= frac; }); gcd = getGCD(n, d); n = n/gcd; d = d/gcd; return [n, 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") : ((CHOSEN === 2) ? "neither" : "none") 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 CHOSEN > 2 ? ", and so on." : "."

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} {PROBS}.

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} {PROBS}.

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

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 _.map(PROBS, function(p){ return "\\dfrac{"+p+"}{"+p+"}"; }).join("\\cdot") = \dfrac{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/ getGCD(NUM_ONE*AFTER_NUM,TOTAL*(TOTAL-1)) TOTAL*(TOTAL-1)/ getGCD(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?" : "?" Write your answer as a simplified fraction.

(NUM_ONE/TOTAL)*(AFTER_NUM/(TOTAL-1))

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}

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_PROB], [(CAPTAIN_DEM-CAPTAIN_NUM) * PIRATE_NUM, CAPTAIN_DEM*PIRATE_DEM, (1-CAPTAIN_PROB)*PIRATE_PROB], [0,1,0]][INDEX]; } else { return [[CAPTAIN_NUM * (PIRATE_DEM-PIRATE_NUM), CAPTAIN_DEM*PIRATE_DEM, CAPTAIN_PROB*(1-PIRATE_PROB)], [PIRATE_NUM, PIRATE_DEM, PIRATE_PROB], [0,1,0]][INDEX]; } })() 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]; } } })()

Captain person(1) and his(1) ship, the H.M.S Crimson Lynx, are two furlongs from the dread pirate person(2) and his(2) merciless band of scallawags.

The Captain has probability C_HIT_PRETTY of hitting the pirate ship, if his(1) ship hasn't already been hit. If it has been hit, he(1) will always miss. The pirate has probability P_HIT_PRETTY of hitting the Captain's ship, if his(2) ship hasn't already been hit. If it has been hit, he(2) will always miss as well.

If the C_FIRST ? "Captain" : "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 C_FIRST ? "Captain" : "pirate" fires first, so his(C_FIRST ? 1 : 2) ship can't be sunk before he(C_FIRST ? 1 : 2) fires his cannons.

So, the probability of EV_A is PR_A.

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

If the C_FIRST ? "Captain" : "pirate" missed the C_FIRST ? "pirate" : "Captain's" ship, the C_FIRST ? "pirate" : "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)