# math

### multiplicitiesoffreedom demonstrates Chaos Theory in Excel. If…

June 29, 2012 |

multiplicitiesoffreedom demonstrates Chaos Theory in Excel. If he filled in more initial values, you would see a thick bar—like a picture of white-noise. Butterflies flapping their wings in Vermont to change the wind in Hangzhou? A drop of water on ... [Read more...]

### How do I Create the Identity Matrix in R?

June 27, 2012 |

I googled for this once upon a time and nothing came up. Hopefully this saves someone ten minutes of digging about in the documentation. You make identity matrices with the keyword diag, and the number of dimensions in parentheses. __ diag(3) [,...

### How to outrun a crashing alien spaceship

June 11, 2012 |

Hollywood movies are obsessed with outrunning explosions and outrunning crashing alien spaceships. For explosions the movies give the optimal (but unusable) solution: run straight away. For crashing alien spaceships they give the same advice, but in this case it is wrong. We demonstrate the correct angle to flee. Running from ... [Read more...]

### How Not To Draw a Probability Distribution

March 7, 2012 |

If I google for “probability distribution” I find the following extremely bad picture: It’s bad because it conflates ideas and oversimplifies how variable probability distributions can generally be. Most distributions are not unimodal. Most dist... [Read more...]

### Error Handling in Lyx & Sweave: using Quantmod (and R, of course)

November 8, 2011 |

I do reports for clients with LyX and Sweave. It took me an extremely long time to get them working, but now that they’re working I can do more in an hour and thus charge more per hour. If you’re not familiar, here’s a rundown: LaTeX is ... [Read more...]

### Prime testing function in R

August 20, 2011 |

I was hoping to begin tinkering a bit with the multicore package in R beyond some extremely trivial examples.  Thanks to a combination of R’s dumb quirkiness (for example, being worthless on loops), my poor planning, and general bad programming, my Saturday afternoon tinkering project is ultimately worthless in ... [Read more...]

### B*tchin’ six dimensional 6-cube. The rainbow colours and…

July 1, 2011 |

B*tchin’ six dimensional 6-cube. The rainbow colours and glass panes really help this visualisation.  Examples of 6-dimensional things If it’s hard to envision 6 dimensions, consider this: the possible tunings of a guitar constitute a 6-dimensio... [Read more...]

### Happy Pi Day, Now Go Estimate It!

March 14, 2011 |

As you may know, today is Pi Day, when all good nerds take a moment to thank the geeks of antiquity for their painstaking work in estimating this marvelous mathematical constant. It is also a great opportunity to thank contemporary geeks for the wonders of modern computing, which allow us ... [Read more...]

### Easiest way to start imagining four-dimensional things is by…

January 15, 2011 |

Easiest way to start imagining four-dimensional things is by numbering the corners of a 4-cube. First realize that the eight corners of a cube can be numbered “in binary” 000—001–010–100—110–101–011—111. Just like the four corners of ... [Read more...]

### Visualizing Facebook Friends: Eye Candy in R

December 18, 2010 |

Earlier this week I published a data visualization on the Facebook Engineering blog which, to my surprise, has received a lot of media covereage. I’ve received a lot comments about the image, many asking for more details on how I … Continue reading → [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...]

### 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...]

### Here is how to improve your charts, graphs, maps, and…

October 2, 2010 |

Here is how to improve your charts, graphs, maps, and plots: Erase non-data ink. Erase redundant data ink. Maximize the ratio of data to ink. Show data variation, not design variation. The surface area of graphical elements should be directly proportio... [Read more...]

### An experiment in A/B Testing my Résumé

July 1, 2010 |

Objective I’ll admit it: my résumé doesn’t stand out. I’ve had some great internships, but also a tendency to work for companies that aren’t (yet!) household names. And though I’m doing fine academically, it’s not well enough to stand out … Continue reading → [Read more...]

### Why R doesn’t suck

June 19, 2010 |

I first encountered the R programming language a few years ago when I needed to make some plots. Although I’ve used it occasionally since, I always considered it a sort of “Perl for statisticians” — a useful swiss-army knife with … Continue reading → [Read more...]

### extrapolation and interpolation The most important lesson I…

May 25, 2010 |

extrapolation and interpolation The most important lesson I learned from this book:  regression is reliable for interpolation, but not for extrapolation.  Even further, your observations really need to cover the whole gamut of causal variables, inter... [Read more...]

### no “Infinities”

March 12, 2009 |

Thanks to  Pierre-Yves for the below useful tip!if you have a dataset from which you want the max or min but they have to be real number and not "Inf" or "-Inf" there is a way to do it:data