Publications by ALT

Kernel Density Estimates & Truncated Normals

24.06.2011

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’s going on? The catch is that this isn’t a plot of the true density, but rath...

1901 sym R (1604 sym/1 pcs) 8 img

Men with Hats

06.07.2011

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?EstimateProbability <- function(n.people, n.simulations=10000) { NobodyGotTheirHat ...

1002 sym R (1186 sym/1 pcs) 4 img

A Plot of 250 Random Walks

22.07.2011

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 <- 100 k <- 250 initial.value <- 10 GetRandomWalk <- function() { # Add a standard normal at each step initial.value + c(0, ...

745 sym R (877 sym/1 pcs) 4 img

A Currency Graph

27.07.2011

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) GetExchangeRates <- function(from, to) { urls <- sprintf("%s/d/quotes.csv?s=%s%s=X&f=b", ...

918 sym R (964 sym/2 pcs) 4 img

A Bayesian Guessing Game

03.08.2011

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 odd numbers, you might draw 3, 5 and 91 (but not 103). Below is some R...

1281 sym R (2846 sym/2 pcs) 2 img

S&P 500 Returns

01.09.2011

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 looking at absolute movements in the index, when we really care about relative c...

1691 sym R (1755 sym/1 pcs) 8 img