# Blog Archives

## S&P 500 Returns

September 1, 2011
By

I'll begin with a familiar image:That plot shows the closing values of the S&P 500 index from 1990 until today. It's a useful representation -- at a glance, you can tell when the market rose and fell. That said, it does have some problems: we're...

## A Bayesian Guessing Game

August 3, 2011
By

You, the player, must think of some set, eg "odd numbers" or "perfect squares," and that'll be your little secret. Now think of some numbers that live in the intersection of your set and the integers {1, 2, ... , 100} -- for example, if you've chosen ...

## A Currency Graph

July 27, 2011
By

Here's a graph in which nodes (and edges) represent currencies (and exchange rates):library(igraph)currencies <- factor(c("EUR", "USD", "JPY", "GBP"))df <- subset(expand.grid(from=currencies, to=currencies), from != to)GetExchangeRate...

## A Plot of 250 Random Walks

July 22, 2011
By

For some reason I feel like plotting some random walks. Nothing groundbreaking, but hopefully this post will be useful to someone. Here's my R code:# Generate k random walks across time {0, 1, ... , T}T <- 100k <- 250initial.value <- 10GetRa...

July 20, 2011
By

A few days ago I heard a talk about Simpson's paradox, and I decided to write a little example in R:library(MASS) # For multivariate normals# List of (vectors of) meansmu <- list(c(5, 175), c(6.25, 110))# List of covariance matricessigma ...

## Men with Hats

July 6, 2011
By

Suppose N people (and their hats) attend a party (in the 1950s). For fun, the guests mix their hats in a pile at the center of the room, and each person picks a hat uniformly at random. What is the probability that nobody ends up with their own hat?E...

## Kernel Density Estimates & Truncated Normals

June 24, 2011
By

Earlier today I read a post about truncated normals, and one plot in particular jumped out at me:By definition, the truncated normal should have zero density everywhere to the left of the truncation point, but that's not what we see in the plot. What'...

## A Little Sampling Puzzle

June 18, 2011
By

Suppose you have 10 objects from which you take a sample of size 20 (with replacement, or you're in trouble). What's the probability that each object was chosen at least once? Getting an answer via simulation is pleasantly easy:f <- function(n=10,...

## Dependence and Correlation

June 13, 2011
By

In everyday life I hear the word "correlation" thrown around far more often than "dependence." What's the difference? Correlation, in its most common form, is a measure of linear dependence; the catch is that not all dependencies are linear. The set...

## On Crows

June 12, 2011
By

Today I made the mistake of clicking on the "Next Blog" button, which took me to a rather inane post complaining that crows are (obviously) stupid (because they are sometimes hit by cars). I was reminded that crows are actually quite smart.