Thursday, February 26, 2015

Unizor - Probability - Easy Problems 3





Problem A

It's about chess.
Two rooks of different color are randomly put on a standard chess board (8x8).
What is the probability they are on the same horizontal or vertical line (that is, one can capture another)?

Solution

The sample space contains all the different positions of two rooks on the board. There are 64 positions for one rook and 63 remaining positions for another. That makes 64·63 elementary events in our sample space, all having the same probability of 1/(64·63).
Now, for every position of one rook, there are 7 positions of another to have both rooks on the same horizontal line and another 7 positions of the second rook to have both on the same vertical line. That make 14 positions of the second rook for each (out of 64) position of the first. The total number of positions of our pair of rooks when one can capture another is, therefore, 64·14.
We can determine the probability of two rooks standing in a position of capturing by multiplying the number of elementary events that satisfy this condition by a probability of each getting
P = (64·14)/(64·63) = 14/63 = 2/9

Problem B

26 letters of English alphabet are randomly written in one line, one after another.
What is the probability of letter Z to be to the right of letter A?

Solution 1 (straight forward)

Our random space contains 26! different permutations of letters. All permutations are equally probable with the probability 1/26!.
Let's count the number of positions of two letters, A and Z, when Z is to the right of A.
For A we have 25 different positions. Counting left to right, they are: 1, 2, 3,...,25 (position #26 cannot be taken since there will be no room for Z).
If A is at position #1, there are 25 different positions of Z that satisfy the condition of it being to the right of A.
If A is at position #2, there are 24 different positions of Z that satisfy the condition of it being to the right of A.
etc...
If A is at position #25, there is only 1 position of Z that satisfy the condition of it being to the right of A.
Therefore, the number of positions of a pair (A,Z) when Z is to the right of A equals to
25+24+...+1=26·25/2=325
With each of these there are 24! of different positions of the other letters. That makes the number of permutations of all letter with Z to the right of A equal to 325·24!.
Since the probability of each equals to 1/26!, the probability of Z to be to the right of A equals to
P = 325·24!/26! =
= 325/(26·25) = 13/26 = 1/2

Solution 2 (smart)

Since there are as many permutations of our letters with Z to the right of A as with Z to the left of A (since we can just exchange their positions), the number of permutations when Z is to the right of A equals to the number of permutations when Z is to the left of A. Therefore, the probabilities of both are equal and there can be no other cases.
Therefore, the probability of Z standing to the right of A is 1/2.


Problem C

Take 16 cards out of a standard deck - four Jacks, four Queens, four Kings and four Aces.
Let's disregard their suits and pay attention only to their rank: any Jack is lower then any Queen, any Queen is lower than any King, any King is lower than any Ace.
Now randomly put them in a row.
What is the probability of them being ordered by rank, that is four Jacks, followed by four Queens, then four Kings and, finally, four Aces?

Solution

This is a combinatorial problem. We have to calculate the number of permutations of 16 cards, knowing that they can be grouped into four groups by rank with cards within each group having the same rank.
The total number of permutations is 16!, but permutations that are different only by the order of cards within each group should be considered identical. Therefore, taking into account that we have 4 groups by 4 indistinguishable by rank cards in each group, we have to divide the total number of permutations by (4!)^4. So, the number of really different permutations is
16!/[(4!)^4]=63,063,000
Therefore, the probability of one specific permutation (when ranks are in order) is
1/63,063,000

Problem D

A square with a diagonal R is inscribed into a circle of a diameter R.
What is a probability that a point randomly placed inside a circle will be inside a square?

Solution
Obviously, the probability of a point to be inside a square equals to a ratio of an area of a square to an area of a circle.
The area of a square with a diagonal R equals to R^2/2.
The area of a circle with a diameter R is πR^2/4.
The ratio of the former to the latter, that is the probability we are calculating, equals to
(R^2/2)/(πR^2/4) = 2/π

Wednesday, February 25, 2015

Unizor - Probability - Advanced Problems 1





Naive gambler decides to play roulette (36 red and black numbers from 1 to 36 to bet on and losing 0 and 00) against a casino, always betting on a color red (with a probability of winning 18/38 and the payoff on par with the bet, that is if you bet 1 bitcoin and win, you get your 1 bitcoin back and another from the house).
The strategy he decides to follow is to quit playing as soon as he wins the first time and, while he loses, to double his bet for each new spin of the wheel.
The first bet is 1 bitcoin. His capital allows him to lose no more than N times in a row, losing 1 bitcoin on the first spin, then 2 bitcoins on the second spin, then 4 bitcoins on the third spin etc. up to 2^(N−1) bitcoins on the Nth spin.

Problem A
What is the minimum amount of money a player needs, if he wants to be able to spin the wheel N times, while losing all the times?

Problem B
What are the elementary events we can define in this game? In other words, what are the mutually exclusive outcomes of this game?

Problem C
What are the probabilities of these elementary events?

Problem D
Prove that the sum of the probabilities of all mutually exclusive outcomes of this game equals to 1.

Problem E
What is the expectation of the winning (or losing) in this game? In other words, what is the average win (or loss) for this naive player?

Problem F
Is this strategy good for a player? Is it better to play it with more money?

Monday, February 23, 2015

Unizor - Probability - Easy Problems 2





Problem A
Assume that the probability of snowing on December 25th is 0.4.
Assume also that the climate is not changing during the next 10 years, so this probability remains constant throughout the years.
What is the probability of snowing on exactly 3 different December 25th dates out of the next 10 years?

Problem B
A discrete random variable takes values
1/2, 1/4, 1/8,...,1/2n,1/2n+1,...
with probabilities, correspondingly,
1/2, 1/4, 1/8,...,1/2n,1/2n+1,....
As you see, there are infinite number of values it can take and, correspondingly, infinite number of probabilities.
(a) Check that the sum of all probabilities equals to 1.
(b) Determine a probability for our random variable to be between 1/2^m and 1/2^n (inclusive, where m is smaller than n).
(c) Calculate the expected value of this random variable.

Problem C

A person is trying to call a friend, but he forgot the last digit of the friend's number. So, he tries to randomly choose the last digit and, if it's a wrong number, tries another digit at the end. Obviously, it requires no more than 10 attempts to succeed.
What is the probability of succeeding no later than on the Nth try, assuming he does not repeat dialing the wrong numbers that he already dialed before?

Unizor - Probability - Easy Problems 1

Problem A
There are 52 cards in the deck, 13 of each suit - spades, hearts, diamonds and clubs. You pick 2 cards out of this deck.
What is the probability that you pick two spades?
Solution
"Classical" approach to this problem calls for calculating the total number of elementary events and the number of "good" elementary events (those that satisfy our condition).
The total number of events is the number of pairs out of 52 cards, that is C[52,2]=(52·51)/(1·2)=26·51.
The number of "good" events is the number of pairs out of 13 spades, that is C[13,2]=(13·12)/(1·2)=13·6
The probability, therefore, is (13·6)/(26·51)=1/17.

Problem B
There are 52 cards in the deck, 13 of each suit - spades, hearts, diamonds and clubs. You pick 1 cards out of this deck.
What is the probability that you pick a card higher in rank than 5 (that is, 6, 7, 8, 9, 10, Jack, Queen, King or Ace)?
Solution 1
This problem can be solved using the additive property of probability. The probability to pick a card of a rank 6 is 4/52=1/13 since there are four such cards in the deck (one for each suit). Exactly the same is the probability to pick a card of a rank 7 or 8, or 9, or 10 or Jack, or Queen, or King, or Ace.
These events are non-intersecting. Therefore, the probability of either one of them is a sum of their probabilities, that is
9·1/13=9/13.
Solution 2
This is, basically, the same solution. But, instead of calculating the probability of our event, we can calculate the probability of the complementary event and then subtract it from 1 (the probability of a certain or complete, or full event).
The complementary event is a combination of picking a card of a rank 2, 3, 4 or 5. There are 16 such cards in the deck (four each in each suit). Therefore, the probability of picking a card of a rank below 6 equals to 16/52=4/13.
The probability of our event will then be 1−4/13=9/13.

Problem C
We roll four dice.
What is the probability of rolling number 6 on, at least, one of them? Is it a good game for you if hitting number 6 at least once is a win? How about hitting 6 at least once on three dice?
Solution
It's easier to calculate the probability of not rolling number 6 on any of them. This is a combination of independent events of not rolling number 6 on each of four dice.
The probability of not rolling 6 on one dice is a sum of probabilities to roll 1 or 2, or 3, or 4, or 5, that is 5/6.
The combination of these events on four dice has a probability equal to a product of their probabilities, that is (5/6)^4.
The probability of a complementary event of rolling, at least, one number 6 is, therefore, 1−(5/6)^4≅0.5177.
This is greater than 1/2 and is a game you would more often win than lose.
With three dice the corresponding answer is 1−(5/6)^3≅0.4213, which is substantially less than 1/2 and definitely is a losing game for you.

Problem D
There are three manufacturers of T-shirts - A, B and C. All of them produce white and non-white T-shirts.
75% of T-shirts produced by A are white.
50% of T-shirts produced by B are white.
25% of T-shirts produced by C are white.
A department store sells T-shirt produced by all three manufacturers and none others.
25% of all T-shirts it purchases wholesale are from the manufacturer A.
35% of all T-shirts it purchases wholesale are from the manufacturer B.
40% of all T-shirts it purchases wholesale are from the manufacturer C.
If you randomly pick a T-shirt sold in this department store, what is the probability of it being white?
Hint
Use the formula of total probability:
P(X) = P(A∩X) + P(B∩X) + P(C∩X)
where events A, B and C are mutually exclusive and cover an entire sample space.
Solution
The event we are interested in can be represented as a sum of three events:
You pick a white T-shirt produced by the manufacturer A, you pick a white T-shirt produced by the manufacturer B or you pick a white T-shirt produced by the manufacturer C.
Let A be an event of picking a T-shirt produced by the manufacturer A,
B be an event of picking a T-shirt produced by the manufacturer B,
and C be an event of picking a T-shirt produced by the manufacturer C.
These events, A, B and C are mutually exclusive and their union covers an entire sample space.
Let X be an event of picking a white T-shirt - this is an event whose probability we have to find.
The representation we talk about can be expressed as the following formula (we use symbol ∩ to represent an intersection and symbol + to represent a union of events):
X=(A∩X)+(B∩X)+(C∩X)
Therefore, using a formula of total probability
P(X) = P(A∩X) + P(B∩X) + P(C∩X)
To find out each of these probabilities, we can use a formula of conditional probability: P(A∩X)=P(A)·P(X|A)
P(B∩X)=P(B)·P(X|B)
P(C∩X)=P(C)·P(X|C)
We know each one of these: P(A) = 0.25
P(B) = 0.35
P(C) = 0.40
P(X|A) = 0.75
P(X|B) = 0.50
P(X|C) = 0.25
This gives the result:
P(X) = 0.25·0.75 + 0.35·0.50 + 0.40·0.25 = 0.4625

Friday, February 13, 2015

Unizor - Probability - Binomial Distribution - Problems 1





Problem A
What are the expected value and the standard deviation of a Binomial random variable that is the number of successes in N=100 Bernoulli trials with probability of success p=0.1?

Solution
As we determined in the lecture about Binomial distribution, the expectation of the number of successes in our case is
E = N·p = 100·0.1 = 10
Standard deviation of our random variable is
σ = √(N·p·(1−p)) = √(100·0.1·0.9) = 3
Therefore, from each randomly chosen 100 parts we can reasonable expect 10 to be defective on average with average deviations from this number to be equal to 3.

Problem B
A machine produces parts for car engines. The probability to produce a defective part equals to p.
How many randomly chosen parts produced by this machine you have to take to expect, on average, D defective parts?

Solution
If N is the number of parts we randomly choose, the expected number of defective parts is N·p, as was explained in the lecture on Binomial distribution. This is the expectation of a random variable that is equal to a number of occurrences of a certain event in a series of Bernoulli trials, if the probability of occurrence in one trial is p.
Therefore, the condition we have to meet is
N·p = D
From this we can determine the number of parts to randomly choose to expect, on average, D defective among them:
N = D/p

Problem C
A machine produces parts for car engines. The measure of the quality of production is the probability to produce a defective part p, which is unknown.
A very large group of N parts is randomly chosen and it contains D defective parts. What would be an estimate of the probability to produce a defective part?

Solution
Notice the words "very large group" and "estimate" in the problem. We cannot exactly tell what is the value of the probability to produce a defective part. However, a good estimate would be a value p that satisfies the equation N·p=D, that is
p ≅ D/N

Problem D
Two dice are rolled and the resulting numbers are added together. If the sum is 7, it's a failure. Otherwise, this is a success.
Assume a game when you roll this pair of dice ten times and, if you fail two or more times (that is, the sum of two numbers equals to 7 in two or more cases out of ten), you lose the game. Otherwise (the sum equals to 7 zero or one time out of ten) you win.
The bet is 1 bitcoin. The payback is also 1 bitcoin.
Is it a good game for the house?

Solution
Clearly we deal here with Binomial distribution.
Let's determine the probability of hitting a sum of 7 (failure) in one roll of a pair of dice.
There are 36 different elementary events when rolling a pair of dice.
The combinations when the sum of two numbers equals to 7 are:
1+6; 2+5; 3+4; 4+3; 5+2; 6+1.
So, we have 6 combinations out of 36 possible, so the probability of hitting 7 (failure) in one roll of a pair of dice equals to 1/6. The probability of hitting non-7 (success), therefore, equals to 5/6
Now we win the game if zero or one out of ten rolls end up in a sum of 7, that is if no more than one failure occurs in ten rolls.

The probability of hitting 7 zero times out of ten equals to 10 times non-7 sums in a row. The probability of this event to happen one time equals to 5/6. Events are independent. So, the probability of 10 such events in a row equals to
P(10 non-7)=(5/6)^10,
which is, approximately, 0.1615.

The probability of hitting 7 exactly one time out of ten is a sum of probabilities to hit 7 on the first roll while having non-7 on all subsequent rolls, to hit 7 on the second roll while having non-7 on a previous and all subsequent rolls,..., to hit 7 on the tenth roll while having non-7 on all previous rolls. Obviously, the total probability equals to
P(9 non-7)=10·(5/6)^9·(1/6),
which is approximately 0.3230.

So, the probability to hit 7 in zero or one case out of ten (when you win the game and the house pays you back) equals to
P(win)=P(0 or 1 failure)≅0.1615+0.3230=0.4815.
As we see, it's slightly less than 0.5. Therefore, in a long run, the house has chances slightly better (probability to win the game for the house is 1-0.4815=0.5185), as it usually has in all games.
Exact calculations of the expected return for the house are:
R = 0.4815·(−1)+0.5185·1 = 0.037
It means that, on average, from each game of ten rolls, when a client bets 1 bitcoin to hit 7 no more than once, the house wins 0.037 bitcoins. Good game for the house.

Saturday, February 7, 2015

Unizor - Probability - Geometric Distribution - Problems 1





Problem A
Assume that the probability of winning on a particular number in roulette equals to P=1/38. The bet is 1 bitcoin. You have exactly 10 bitcoins.
What is the probability of losing 9 times in a row and winning on the last bitcoin left?

Solution
The probability of winning is P=1/38 and the probability of losing is 1−P=37/38.
All games are independent, so the probability of their combination equals to a product of their probabilities.
Therefore, a sequence of 9 losses and 1 winning has a probability of
[(1−P)^9]·P = [(37/38)^9]·(1/38) ≅ 0.02

Problem B
Let's expand the previous problem and assume that winning in the 1st or the 2nd or any other game up to 10th are also what we consider as an ultimate success because we end up with money, while losing the ten games in a row would bankrupt us and should be considered as an ultimate failure.
What is the probability of ultimate success?

Solution 1
The easy solution is to calculate the probability of a failure, that is the probability of 10 losses in a row.
This is equal to
(37/38)^10 ≅ 0.7659
Therefore, the probability of success is
1 − (37/38)^10 ≅ 0.2341

Solution 2
On the other hand, we can calculate 10 different probabilities of winning in the 1st game, in the 2nd game etc. up to 10th game and add them up.
This would be a sum of a geometric progression with the first member a=1/38 and the factor d=37/38.
The sum of the 10 members of this geometric progression equals to
S = 1/38+37/(38^2)+...+(37^8)/(38^9)+(37^9)/(38^10)
To summarize this geometric progression without using a formula, which only few people remember, let's multiply this sum by a factor:
S·(37/38) = 37/(38^2)+...+(37^9)/(38^10)+(37^10)/(38^11) =
= S − (1/38) + (37^10)/(38^11)
Now we can consider this as an equation for an unknown S that can be easily solved:
S·[1-(37/38)] =
= (1/38)·[1-(37/38)^10]
Hence,
S/38 = (1/38)·[1-(37/38)10]
Therefore,
S = 1-(37/38)^10 ≅ 0.2341
The same exactly answer as in the Solution 1
.
Problem C
Assume you are playing the following game.
Two dice are rolled and the resulting numbers are added together. If the sum is N, you win. Otherwise, you lose.
What should N be if you would like the average number of experiments until the first winning to be equal to 6?

Solution
Since we are talking about the number of experiments until the first success, this is an example of a geometric distribution.
The probability of success p is the probability of a sum of two numbers rolled on two dice to be N.
Obviously, probability p is a function of the number N. If, for example, N is less than 2 or greater than 12, the probability of success equals to 0 since any experiment results in the sum of two numbers to be between 2 and 12.
The average number of experiments until the first success for a geometrically distributed random variable with the probability of success p equals to 1/p, as we know from the lecture on properties of geometric distribution, and is given in this problem as being equal to 6.
Therefore, we can determine the probability of success. If 1/p=6, p must be equal to 1/6.
All we have to do is to determine N from a statement that the probability of a sum of two numbers to be equal to N is 1/6.
This is a combinatorial problem.
Let's research the number of combinations that lead to each value of a sum of two numbers on rolled dice.
N=2: 1+1 (1)
N=3: 1+2;2+1 (2)
N=4: 1+3;2+2;3+1 (3)
N=5: 1+4;2+3;3+2;4+1 (4)
N=6: 1+5;2+4;3+3;4+2;5+1 (5)
N=7: 1+6;2+5;3+4;4+3;5+2;6+1 (6)
N=8: 2+6;3+5;4+4;5+3;6+2 (5)
N=9: 3+6;4+5;5+4;6+3 (4)
N=10: 4+6;5+5;6+4 (3)
N=11: 5+6;6+5 (2)
N=12: 6+6 (1)
The total number of combinations of numbers on two dice is, obviously, 6·6=36. The only value of the sum of two numbers that gives the probability 1/6 is N=7 with 6 different combinations of two numbers since 6/36=1/6. All other values of N are rarer than this and, therefore, their probabilities are less than 1/6. Therefore, the solution of this problem is N=7.
If, for example, the problem stated that the average number of experiments until the first success must be equal to 9, the solution would be either N=5 with 4 combinations or N=9 with 4 combinations because 4/36=1/9.