~/ learn/ comp-456/ cards/ Reasoning Under Uncertainty
1 of 23

Compute nCr(5,2), nPr(5,2), and the European-roulette expectation 35·(1/37) + (−1)·(36/37). Print all three.

Compute nCr(5,2), nPr(5,2), and the European-roulette expectation 35·(1/37) + (−1)·(36/37). Print all three.

Answer

from math import factorial def nPr(n, r): return factorial(n) // factorial(n - r) def nCr(n, r): return factorial(n) // (factorial(n - r) * factorial(r)) # Roulette: win 35 with p = 1/37, lose 1 with p = 36/37 e_roulette = 35 * (1 / 37) + (-1) * (36 / 37) print(f"nCr(5,2)={nCr(5, 2)}") print(f"nPr(5,2)={nPr(5, 2)}") print(f"E[roulette] = {e_roulette:.3f}")

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/1c2f44cb-da6c-4363-ab31-2566d120352c/flashcard utf-8 LF