# Probability

### Visualising the Metropolis-Hastings algorithm

February 10, 2012 |

In a previous post, I demonstrated how to use my R package MHadapive to do general MCMC to estimate Bayesian models. The functions in this package are an implementation of  the Metropolis-Hastings algorithm. In this post, I want to provide an intuitive way to picture what is going on ‘under ... [Read more...]

### Gauging Interest in a Montreal R User Group

February 7, 2012 |

Some of us over at McGill’s Biology Graduate Student Association have been developing and delivering R/Statistics workshops over the last few years. Through invited graduate students and faculty, we have tackled  everything from multi-part introductory workshops to get your feet wet, to special topics such as GLMs, GAMs, ... [Read more...]

### General Bayesian estimation using MHadaptive

February 6, 2012 |

If you can write the likelihood function for your model, MHadaptive will take care of the rest (ie. all that MCMC business). I wrote this R package to simplify the estimation of posterior distributions of arbitrary models. Here’s how it works: 1) Define your model (ie the likelihood * prior). In ... [Read more...]

### Monty Hall by simulation in R

February 3, 2012 |

(Almost) every introductory course in probability introduces conditional probability using the famous Monte Hall problem. In a nutshell, the problem is one of deciding on a best strategy in a simple game. In the game, the contestant is asked to select one of three doors. Behind one of the doors ... [Read more...]

### Uncertainty in markov chains: fun with snakes and ladders

December 31, 2011 |

I love board games. Over the holidays, I came across this interesting post over at Arthur Charpentier’s Freakonometrics blog about the classic game of snakes and ladders. The post is a nice little demonstration of how the game can be formulated completely as a Markov chain, and can be ... [Read more...]

### Visualizing Sampling Distributions

September 25, 2011 |

Teacher: “How variable is your estimate of the mean?” Student: “Uhhh, it’s not. I took a sample and calculated the sample mean. I only have one number.” Teacher: “Yes, but what is the standard deviation of sample means?” Student: “What do you mean means, I only have the one ... [Read more...]

### Visualizing Bayesian Updating

September 10, 2011 |

One of the most straightforward examples of how we use Bayes to update our beliefs as we acquire more information can be seen with a simple Bernoulli process. That is, a process which has only two  possible outcomes. Probably the most commonly thought of example is that of a coin ... [Read more...]

### Hey! I made you some Wiener processes!

September 7, 2011 |

Check them out. Here are thirty homoskedastic ones: __ homo.wiener for (j in 1:30) {  for (i in 2:length(homo.wiener)) {          homo.wiener[i,j] for (j in 1:30) {        plot( homo.wiener[,j],           type = "l", col = rgb(.1,.... [Read more...]

### Using simulation to demonstrate theory: Hardy-Weinberg Equilibrium

June 13, 2011 |

One of my teaching roles is in an introductory Genetics course, where first year students are presented with a wide range of new ideas at a relatively fast pace.  It seems that often, students choose to take a memorization approach to learning the material, rather than taking the chance to ... [Read more...]

### Example 8.36: Quadratic equation with real roots

April 29, 2011 |

We often simulate data in SAS or R to confirm analytical results. For example, consider the following problem from the excellent text by Rice:Let U1, U2, and U3 be independent random variables uniform on [0, 1]. What is the probability that the roots...

### when Nuns or Hells Angels get in a plane

February 24, 2011 |

Today, at lunch, Matthieu told us a nice story (or call it a paradox if you like) about the probability to find you seat empty when you get in a place.  a plane full of nuns Assume that you are in the line to get in the airplane, you are ... [Read more...]

### Estimate Probability and Quantile

January 25, 2011 |

Simple root finding and one dimensional integrals algorithms were implemented in previous posts. These algorithms can be used to estimate the cumulative probabilities and quantiles. Here, take normal distribution as an example. Read More: 281 Words Totally [Read more...]

### cumsum ( rnorm(50), lend="butt", lwd=12, type="h" ) Cumulative…

December 8, 2010 |

cumsum ( rnorm(50), lend="butt", lwd=12, type="h" ) Cumulative sum of 50 draws from a normal distribution. File this under mysteries of the Central Limit Theorem. [Read more...]

### Some ideas on communicating risks to the general public

December 3, 2010 |

SOME EMPIRICAL BASES FOR CHOOSING CERTAIN RISK REPRESENTATIONS OVER OTHERS This week DSN posts some thoughts (largely inspired by the work of former colleagues Stephanie Kurzenhäuser, Ralph Hertwig, Ulrich Hoffrage, and Gerd Gigerenzer) about communicating risks to the general public, providing references and delicious downloads where possible. Representations to ... [Read more...]

### Livin’ la Vida Poisson

November 5, 2010 |

Yes, I did just mix English, Spanish and French. And no, I living the “fishy” life, popular opinion to the contrary. Here’s the story. As someone who spends the majority of his time working online, with no oversight, I notice that I tend to drift a lot. I don’... [Read more...]

### A million ? what are the odds…

October 27, 2010 |

50 days ago, I published a post, here, on forecasting techniques. I was wondering what could be the probability to have, by the end of this year, one million pages viewed (from Google Analytics) on this blog. Well, initially, it was on my blog at t... [Read more...]

### Central Limit Theorem A nice illustration of the Central Limit…

October 20, 2010 |

Central Limit Theorem A nice illustration of the Central Limit Theorem by convolution.in R: Heaviside 0,1,0) }HH [Read more...]

### The Chosen One

August 30, 2010 |

Toss one hundred different balls into your basket. Shuffle them up and select one with equal probability amongst the balls. That ball you just selected, it’s special. Before you put it back, increase its weight by 1/100th. Then put it back, mix up the balls and pick again. If ... [Read more...]

### R: Clash of the cannon cycles

July 19, 2010 |

Imagine a unit square. Every side has length 1, perfectly square. Now imagine this square was really a fence, and you picked two spots at random along the fence, with uniform probability over the length of the fence. At each of these two locations, set down a special kind of cannon. ... [Read more...]

### 100 Prisoners, 100 lines of code

July 9, 2010 |

In math and economics, there is a long, proud history of placing imaginary prisoners into nasty, complicated scenarios. We have, of course, the classic Prisoner’s Dilemma, as well as 100 prisoners and a light bulb. Add to that list the focus of this post, 100 prisoners and 100 boxes. In this game, ...