Skip to main content

Posts

The Two Strategies

Follow @ProbabilityPuz Q: You are in a game where you get to toss a pair of coins once. There are two boxes (A & B) holding a pair each. Box A's coins are fair however B's coins are biased with probability of heads being \(0.6\) and \(0.4\) respectively. You are paid for the expected number of heads you will win. Which of the boxes should you pick? Machine Learning: The Art and Science of Algorithms that Make Sense of Data A: The expected number of heads if you chose box A is easy to calculate as $$ E(\text{heads}| A) = \frac{1}{2} + \frac{1}{2} = 1 $$ However the expected number of heads if you chose box B is also the same $$ E(\text{heads}| B) = \frac{4}{10} + \frac{6}{10} = 1 $$ The average yield being the same could make one think that both boxes yield the same. However there is one difference, its the variance. The variance of a distribution of a random variable \(X\) is defined as $$ Var(X) = \sum_{i=0}^{N} (x_i - \bar{x})^{2}p_i $$ where ...

Linear Regression, Transforms and Regularization

Follow @ProbabilityPuz This write up is about the simple linear regression and ways to make it robust to outliers and non linearity. The linear regression method is a simple and powerful method. It is powerful because it helps compress a lot of information through a simple straight line. The complexity of the problem is vastly simplified. However being so simple comes with its set of limitations. For example, the method assumes that after a fit is made, the differences between the predicted and actual values are normally distributed. In reality, we rarely run into such ideal conditions. Almost always there is non-normality and outliers in the data that makes fitting a straight line insufficient. However there are some tricks you could do to make it better. Statistics: A good book to learn statistics As an example data set consider some dummy data shown in the table/chart below. Notice, value 33 is an outlier. When charted. you can see there is some non-linearity in the...

The Lazy Apprentice

Follow @ProbabilityPuz Q: A shopkeeper hires an apprentice for his store which gets one customer per minute on average uniformly randomly. The apprentice is expected to leave the shop open until at least 6 minutes have passed when no customer arrives. The shop keeper suspects that the apprentice is lazy and wants to close the shop at a shorter notice. The apprentice claims (and the shopkeeper verifies), that the shop is open for about 2.5hrs on average. How could the shopkeeper back his claim? Statistics: A good book to learn statistics A: Per the contract, at least 6 minutes should pass without a single customer showing up before the apprentice can close the shop. To solve this lets tackle a different problem first. Assume you have a biased coin with a probability \(p\) of landing heads. What is the expected number of tosses before you get \(n\) heads in a row. The expected number of tosses to get to the first head is simple enough to calculate, its \(\frac{1}{p}\). ...

The Best Books for Time Series Analysis

Follow @ProbabilityPuz If you are looking to learn time series analysis, the following are some of the best books in time series analysis. Introductory Time Series with R (Use R!) This is good book to get one started on time series. A nice aspect of this book is that it has examples in R and some of the data is part of standard R packages which makes good introductory material for learning the R language too. That said this is not exactly a graduate level book, and some of the data links in the book may not be valid. Econometrics A great book if you are in an economics stream or want to get into it. The nice thing in the book is it tries to bring out a oneness in all the methods used. Econ majors need to be up-to speed on the grounding mathematics for time series analysis to use this book. Outside of those prerequisites, this is one of the best books on econometrics and time series analysis. Pattern Recognition and Machine Learning (Information Science and Statis...

Two Quick Puzzles

Follow @ProbabilityPuz The following are two puzzles which look tough at first but have quick and really elegant solutions. Q1: Ants on a wire: A large number of ants are on a wire of length \(L\). All ants start moving randomly, either right or left with a fixed velocity \(V\). If they collide they turn around and move in the opposite direction. Ants at the ends of the wire fall off. What is the time taken for all ants to fall off the wire? Q2: The Unruly Passenger: Several passengers are in a queue to board a plane. The first passenger in the queue is an unruly one and chooses a seat at random. Subsequent passengers take their allotted seat if it is unoccupied or pick a seat at random if it is occupied. What is the probability that the last passenger gets to sit on his allotted seat? Statistics: A good book to learn statistics A1: This seemingly complex problem has an elegantly simple solution. The fact that they collide and turn around is the same as if they wa...

Three Random Numbers

Follow @ProbabilityPuz Q: You play a game with a friend where he chooses two random numbers between 0 and 1. Next you choose a random number between 0 and 1. If your number falls between the prior two numbers you win. What is the probability that you would win? A: Consider the number line between 0 and 1 shown in figure below Let \(x\) and \(y\) be the two numbers chosen. The probability of a win, i.e. choosing a number in the range between the two chosen numbers can be estimated as \(\frac{|y-x|}{1}\). Note, we have chosen the modulus operation because \(x\) could be greater than \(y\) or vice versa. The feasible region of numbers to be chosen to win, is the ratio of the absolute difference between \(x\) and \(y\) divided by the total possible range, which is 1. In order to estimate the probability that a third chosen number will lie between the two we integrate out (a double integral) between the ranges of \([0,1]\). This is estimated as $$ P(\text{win}) = \int_{...

The Three Magical Boxes

Follow @ProbabilityPuz Q: You are playing a game wherein you are presented 3 magical boxes. Each box has a set probability of delivering a gold coin when you open it. On a single attempt, you can take the gold coin and close the box. In the next attempt you are free to either open the same box again or pick another box. You have a 100 attempts to open the boxes. You do not know what the win probability is for each of the boxes. What would be a strategy to maximize your returns? Machine Learning: A Probabilistic Perspective (Adaptive Computation and Machine Learning series) A: Problems of this type fall into a category of algorithms called "multi armed bandits". The name has its origin in casino slot machines wherein a bandit is trying to maximize his returns by pulling different arms of a slot machine by using several "arms". The dilemma he faces is similar to the game described above. Notice, the problem is a bit different from a typical estimatio...