Skip to main content

Posts

Showing posts from December, 2012

The Magician's Coin Tossing Experiment

Q: A magician calls you in and using his magical powers claims to make all coin tosses he does fall a heads. You challenge him, and he tosses the coin once and the coin falls heads. What is the probability that he actually has magical powers? He tosses it again, and it falls heads. What is the probability now that he actually has magical powers?

A: This is classic Bayesian. Assume you have a low belief in this person. Set it as 'p'. He flips the first coin and it lands a heads. This new evidence, which favours the hypothesis must lead us to adjust our belief in our value of 'p'. This may not seem intuitive at first glance, partly because the amount of information is very small (1 toss). But lots of real world problems deal with scarce data (more on that on a later post).

Here is an earlier post describing Bayesian reasoning. So, to cast it in that same framework lets start with our hypothesis.

Hypothesis H = Magical Powers Exist
Evidence    E  = 1 heads seen on a coin t…

Lottery Raffle Optimization Puzzle

Q: You participate in an raffle. You have bought a certain number of raffle tickets and there are several prizes to choose from. Assuming you don't care amongst the prizes, do you put all your tickets in one box or distribute them across all the boxes?

A: Several offices have these kind of raffles internally during holiday seasons (Christmas) and I thought it would be worthwhile to formalize it with some proofs and simulations. Assume you have bought "r" tickets and that there are "N" total tickets outside of the "r" you bought. Also assume that there are "m" prizes to be won. You are faced with two broad options.

1) Put them all in one box.
2) Put them evenly in all the boxes. That is, each box gets r/m raffle tickets.

An example of the two options is shown below.


If you assume that all the other raffle tickets are placed evenly, then the probability of winning a prize, should you go with option 1 is simply


If you go with option 2: to compu…

The Naive Bayesian Approach to Machine Learning

On this write up, I'll explain the Naive Bayesian (NB) approach that is used in machine learning. First of, the "naive" in NB is part of the name, not an adjective added. The method is simple, robust and fairly effective for a lot of cases. Every engineer dealing with data absolutely must know this technique. It is one of those techniques which is simple and computable yet fairly simple to explain to people without a machine learning background.

Machine Learning: A Probabilistic Perspective (Adaptive Computation and Machine Learning series)

To start with, let us look at some data. Assume you run  a coffee shop. You keep a log of the gender of every customer along with their age which you estimate. Granted this estimation may not be accurate, but it should be reasonably within range. You also keep track of whether the customer bought a coffee cup that you had put up prominently on display. The data is shown in the table below


GenderAgeBuy Cup (Y/N)Mteenn Mteenn Mmiddley Mmi…

The Sultan's Dowry Puzzle

Q: A sultan has a 100 daughters. Each of them has a fixed amount of dowry associated. Nothing is known about the distribution of dowry amounts among the princesses. You are to pick one of them. You are allowed to know the dowry amount following which you have to make a decision on whether to accept that princess or not. If you reject the princess you move on to the next princess and you cannot come back to the princess you have rejected. Your goal is to pick the princess with maximum amount of dowry. What should your optimal strategy be and what is your probability of success?

The Probability Tutoring Book: An Intuitive Course for Engineers and Scientists (And Everone Else!)

A: This one is a classic problem and there is adequate coverage around the web on how to solve this particular puzzle (which is also popularly called the secretary problem/interviewer problem etc). It is also a great introduction to one of the most interesting areas in probability (multi arm bandits/optimal stoppin…