In [5]:
from scipy.special import comb, factorial
factorial(6)
Out[5]:
In [2]:
factorial(75)
Out[2]:
In [1]:
5**3
Out[1]:
In [4]:
comb(100, 5)
Out[4]:
In [5]:
comb(100, 10)
Out[5]:
Now we need to know how many ways each combination of 10 can be permutated into different teams. Let's consider 4 characters broken up into two teams to simplify. Let's represent the permutations as a sequence of numbers (e.g., 1234). Take the first two numbers as team A and the second two as team B. So the permutation 1234 is equivalent to 2134, 1243, and 2143. See the pattern? Every 4 permutations are equivalent to the teams becasue we can rearrange team A, team B or team A and team B. Mathematically, we have $n!$ permutations and can rearrange one of the teams by $\frac{n}{2}!$ without changing who's on the team. Since we can change both teams, that's $\frac{n}{2}! \times \frac{n}{2}!$. This gives a proposed equation:
$$\frac{n!}{\left(\frac{n}{2}\right)!\left(\frac{n}{2}\right)!}$$Let's test it for 4. There are three teams we can make: 12 vs 34, 13 vs 24, 14 vs 23. The equation gives:
$$\frac{4!}{\left(\frac{4}{2}\right)!\left(\frac{4}{2}\right)!} = \frac{4\times 3 \times 2 \times 1}{(2 \times 1) (2 \times 1)} = \frac{4 \times 3}{2 \times 1} = 6$$It overcounted by 2. Why? Because we didn't consider that we can switch the labels of team A and team B! Knowing that, we can arriave at the correct equation:
$$\frac{n!}{2\left(\frac{n}{2}\right)!\left(\frac{n}{2}\right)!}$$Pluggin the numbers, we get
$$\frac{10!}{2\left(\frac{10}{2}\right)!\left(\frac{10}{2}\right)!}$$
In [6]:
factorial(10) / (2 * factorial(5) * factorial(5))
Out[6]:
In [7]:
comb(100, 10) * 126
Out[7]:
The answer is 2,181,098,991,511,440 or 2.2 quadrillion
In [8]:
comb(100, 5) * comb(95, 5) / 2
Out[8]:
$S$ is a random variable. $P(S=s)$ is a probability.
$P(S = s): P(S=7) = \frac{6}{36} \,\textrm{and}\, P(S=2) = \frac{1}{36}$
$S$ :2 and 12
$s$ was not specified, so our result should be a function!
$$P(S = s\,|\, loss) = \frac{P(loss, S = s)}{P(loss)}$$$$P(loss, S = s) = \left\{\begin{array}{lr}\\ P(S = s) & s = 2, 3, \textrm{or}\,12\\ 0 & \textrm{otherwise}\\ \end{array}\right.$$$$P(loss) = \sum_s P(loss, S = s) = P(S = 2) + P(S = 3) + P(S = 12) = \frac{4}{36}$$Answer
$$P(S = 2\,|\,loss) = \frac{36}{4}\frac{1}{36} = \frac{1}{4}$$$$P(S = 3\,|\,loss) = \frac{36}{4}\frac{2}{36} = \frac{2}{4}$$$$P(S = 12\,|\,loss) = \frac{36}{4}\frac{1}{36} = \frac{1}{4}$$To play the megamillions, you chose 5 unique numbers from 1 to 75 and then one number from 1 to 15 that can overlapp with the previous 5. The first 5 numbers are note replaced, meaning during the drawing there are no repeated numbers. Each ticket costs \$2. Consider the following:
In [2]:
from scipy.special import comb, factorial
comb(75, 5) * 15
Out[2]:
It is left unspecified, but the random variable is the amount of money you win. Let this be $P(A=a)$, where $A$ means amount won. There are two values it can be: the jackpot and 0. The expected value equation is:
$$E[A] = \sum_a P(A = a)a = \frac{J}{258,890,850} + 0\times \left(1 - \frac{1}{258,890,850}\right)$$$$E[A] = \frac{J}{258,890,850}$$If no one wins, that's 517 million sequential loses. The probability of that is:
$$\prod_i^N \left(1 - \frac{1}{258,890,850}\right) = \left(1 - \frac{1}{258,890,850}\right)^N$$You can use $N-1$ or $N$ here, depending on your definition of you and everyone playing. The answers are the same to 10 decimal places.
$$P(\textrm{no wins}) = 0.135$$
In [4]:
N = 258890850.0
print((1 - 1 / N)**(2 * N))
print((1 - 1 / N)**(2 * N - 1))
This is asking about the probability that there is at least one other winner. The probability of that is the complement of 3.5. We now have a different possible amount won values: you win alone, there is at least one other winner and you won, or you don't win. Notice these are $P(A = a)$ values. Let's compute these probabilities:
$$P(\textrm{you win})\times P(\textrm{no one wins}) = \left(\frac{1}{258,890,850}\right)\times 0.135$$$$P(\textrm{you win})\times [1 - P(\textrm{no one wins})] = \left(\frac{1}{258,890,850}\right)\times 0.865$$$$P(\textrm{you don't win}) \times P(\textrm{no one wins or someone wins}) = \left(1 - \frac{1}{258,890,850}\right) \times 1$$The reason we have an or in the last statement because that is for $P(A = \$0)$, which can happen many ways. Now to compute expectation.
$$E[A] = \left(\frac{1}{258,890,850}\right)\times 0.135 \times J + \left(\frac{1}{258,890,850}\right)\times 0.865 \times \frac{J}{2} + 0$$and we know $J = \$517,781,700$, because that comes out of our assumptions that led to the $N$ value. Thus:
$$E[A] = \$2 \times 0.135 + \$1 \times 0.865 = \$1.135$$You are a baby being carried in a stork to your parents. Your parents live in either:
The probability of your birth location is proportional to the populations. As a baby, you are concerned with your career options, which are
Answer the following using $B$ as the random variable for birthplace and $J$ as the random variable for job. We have the following information:
$$P(J = r \,|\, B = c) = 0.05$$$$P(J = d \,|\, B = c) = 0.5$$$$P(J = r \,|\, B = u) = 0.8$$$$P(J = p\,|\, B = u) = 0.01$$$$P(J = p\,|\, B = g) = 0.75$$$$P(J = d \,|\, B = g) = 0.2$$We can use marginalization of the conditional to get this value:
$$P(J = r) = P(r\,|\,c)P(c) + P(r\,|\,u)P(u) + P(r\,|\,g)P(g)$$$$P(J = r) = 0.05\times \frac{1300}{320 + 80 + 1300} + 0.8\times\frac{320}{320 + 80 + 1300} + (1 - 0.2 - 0.75)\times\frac{80}{320 + 80 + 1300}$$$$P(J = r) = 0.19)$$
In [2]:
pop = 320 + 80 + 1300
0.05 * (1300 / pop) + 0.8 * 320 / (pop) + (1 - 0.2 - 0.75) * 80 / pop
Out[2]:
In [7]:
(1 - 0.05 - 0.5) * 1300 / pop
Out[7]:
We can use Bayes' theorem to switch the conditional to be like the previous problem. We'll use "not a rockstar" to compute Z for many of the conditionals.
$$P(B = u \,|\, Z) = \frac{P(Z \,|\, B = u)P(u)}{P(Z)}$$$$P(Z) = P(Z \,|\, B = u) P(u) + P(Z \,|\, B = g) P(g) + P(Z \,|\, B = c)P(c)$$$$P(Z) = (1 - 0.8)\frac{320}{1300 + 80 + 320} + 0.95 \frac{80}{1300 + 320 + 80} + 0.95\frac{1300}{320 + 80 + 1300} = 0.81$$
In [4]:
pz = 0.2 * 320 / pop + 0.95 * 80 / pop + 0.95 * 1300 / pop
ans = ((1 - 0.8) * 320 / pop) / pz
print(ans)