Generating Altered Probabilities

Everyone knows the regular probability functions that you get from rand() or Math.random() or whatever your language happens to use. These are continuous distributions, meaning that they return all values between 0 and the maximum with equal probability:

Since the probabilities must sum to 1, the probability of any particular number then is max-1.

Well, I want the header for my blog. This site is vaguely Viking themed, so I thought I would go with a ship sailing at night. Since I can't draw, I went to Open Clip Art and found something. Since it's a vector graphic, I thought I'd use Inkscape to put everything together.

The tricky part turned out to be the night sky in the background. I started off using a pattern, but there were problems:

So, I decided that I would just generate the stars using javascript. Firefox would then show them and when generating the images for other browsers, Batik would generate them as well. I figured as long as I was going to dynamically generate them, I wanted fewer stars at the horizon than in the rest of the sky. Essentially what I wanted was a probability distribution like this:

This is how it came out:

The Transformation Methods chapter from Numerical Recipes was quite helpful.

My final blog header is: