#!/usr/bin/env python # coding: utf-8 # # Install Python! # # 1. Install necessary python packages by following the instructions in following page*(20 points)*: # # [http://btabibian.github.io/notebooks/learnpython/scientific-computing/2015/04/15/lecture-0-scientific-computing-with-python.html#installation](http://btabibian.github.io/notebooks/learnpython/scientific-computing/2015/04/15/lecture-0-scientific-computing-with-python.html#installation) # # 2. Study Lecture 0 and Lecture 1 from [http://btabibian.github.io/notebooks/learnpython/](http://btabibian.github.io/notebooks/learnpython/) # # Let's play Poker! # # During a game of poker, you are dealt a five-card hand at random from a card deck. A card deck contains 52 cards. There are four suits, Spades, Clubs, Diamonds and Hearts. Each suit has 13 ranks. # # Compute following probabilities: # # 1. $\mathbb{P}(\text{1 pair})$: You have a *pair* if there are only two cards of same rank and the rest are cards of other ranks.*(10 points)* # 2. $\mathbb{P}(\text{2 pairs})$: You have *two pairs* if there are two pairs of cards and each pair has cards of same rank but from different suits.*(10 points)* # 3. $\mathbb{P}(\text{2 pairs} \vert \text{if there is no card of Spades})$: # You look over the shoulder of the person next to you for a second and find out she does not have any card of Spades. How can you update your estimate that she might have a pair in her hand? How about two pairs? # Provide two methods of estimation. One by counting, similar to earlier parts, and other by using the Bayes Rule*(20 points)*: # \begin{equation} # P(A|B) = \frac{P(B | A)\, P(A)}{P(B)} # \end{equation} # # *A similar probabilistic scheme is widely used to play online Poker games. One of the most famous players using this method was Nate Silver, author of [Signal and the noise](http://www.amazon.com/The-Signal-Noise-Predictions-Fail-but/dp/0143125087). He gave up his job at a good paying financial institution to play online Poker games. You can read his story as well as many other stories in using probabilistic models for predicting future in this book.* # # Transformation of Random Variables # # Let X have distribution function # # \begin{align} # F_X(x) = \left\{ # \begin{array}{l l} # 0 & \text{if $x<0$,}\\ # \frac{1}{2}x & \text{if $0 \leq x \leq 2$}\\ # 1 & \text{if $x > 2$}\\ # \end{array} \right. # \end{align} # # Let $Y=X^2$. # Compute the following: # # 1. $\mathbb{P}(\frac{1}{2} < X \leq \frac{3}{2})$ *(10 points)* # # 2. $\mathbb{P}(Y < X)$ *(10 points)* # # 3. distribution function of $Z = \sqrt{X}$ *(10 points)* # # Keep Rolling! # # What is the expected number of times one needs to throw a die to get a 6? *(10 points)* # # *Hint: There are two possible ways to solve this problem, one is by characterizing the number of times needed to get a six as a Geometric distribution and one by using law of total expectation.* # # *This is a job interview question! of course without the hint.* :-)