Math

Generating Normally Distributed Random Numbers in JavaScript

JavaScript's pseudo-random number generator Math.random() outputs what you want a pseudo-random number generator to output: a random number uniformly distributed between 0 and 1. Great, but say you are in a situation where you don't want every number to be equally likely, you want them evenly distributed about a mean. You want a normally distributed random number. To get this you can use the Box-Muller transformation on two uniformly distributed random numbers. Problem solved!

Click to launch demo
normal preview

In this demonstration I use the Box-Muller transformation on numbers generated by JavaScript's Math.random() and use the Kolmogorov-Smirnov test to compare the result against a normal cdf table generated by Mathematica to see if they actually come out normally distributed.

Undergraduate Grades Chronologically

Here's round two of me playing with representing my undergraduate grades. This time I've used Processing which is a neat programming environment for doing these kind of visual sketches.

Visualization of Undergraduate Grades

I was thinking today that now I have all my undergraduate grades and they represent the largest set of quantitative data I have about myself. So, I started analyzing them and thinking of interesting ways represent them. This is the first thing I came up with:

Grades By Department

"Triangulate" Algorithm in Javascript

Now that the semester is over I thought I would update my nifty Javascript polygon triangulation demo which I first created in February of 2009 as practice for a computational geometry class and promptly didn't touch for a year and a half. It is now interactive (it allows you to draw your own polygon), comes with examples (those that I remember from the class) and works in all modern browsers thanks to the magic of jQuery and excanvas. jQuery is far and away my favorite Javascript library for doing anything and excanvas allows Internet Explorer to join the HTML5 canvas tag party. For the next version of this thing I would like to have an option to explain the ear-clipping algorithm it uses as it goes through rather than just showing it in action.

Check it out at my Stony Brook site.
an example triangulation