Friday, December 9, 2011


In re this post, there actually is a simple way to bet against gold, which is by buying a gold short fund like DGZ. Which if I had done it in May of last year, I'd be down to like 55% of my investment. But that means it's a perfect time to buy, right?

Wednesday, May 4, 2011

Good enough or worse than not at all

I was reminded recently of an idea mentioned in an xkcd mouseover text: to keep yourself from being distracted by crap on the internet, put a 30-second delay before opening up a new webpage. I searched and someone had wroten a little script to do that.

I don't know if I screwed something up installing it or whatever, but the script appears to work erratically: sometimes correctly, sometimes showing a countdown on its icon but not obscuring the page, and sometimes having no effect at all.

The upshot being, the anti-distraction mechanism itself ends up replicating the "slot machine" sort of dynamic that makes things like web forums, Twitter feeds, and news sites so distracting in the first place. Being able to instantly check Reddit for new stories whenever you want is habit-forming, but only being able to do so 10% of the time is even worse!

Anyway, just found that amusing or whatever.

Wednesday, April 27, 2011


I wanted to be able to generate random but plausible celestial spheres of stars visible to the naked eye from the vantage point of a solar system like ours, situated in an arm of a spiral galaxy.

I grabbed all the stars in ESA's Hipparcos catalogue with apparent magnitudes below 6, which comes to a little over 5000 stars. Mapped out on a sphere according to apparent magnitude and color they look like:

Stars visible by naked eye from Earth

That's a sinusoidal projection of the whole sphere, as would be seen from inside of it (on the Earth, for example). I sanity-checked it by filtering out all but the stars of the Big Dipper and made sure it dipped in the right orientation and hemisphere.

Plotting their absolute magnitudes versus their color index looks like this:

Plot of each visible star's absolute magnitude versus color index

The hunk on the left is made of stars on the main sequence, and the other splotch of giants, with a spattering of others. Most of the stars around us are red dwarrows, but since they're too small and dim to see with the naked eye, I don't even care about those.

A histogram (excuse the rotation and scaled-up x-axis) looks like:

Histogram of visible stars' magnitudes and colors

I smoothened that out to make a probability distribution (scaled up, and apologies for yet another axis rotation):

Distribution for randomly generating stars of different magnitudes and colors

You can't see it, but outside the main globs there are big regions of "off-white" (grays 253 and 254) where there are small but nonzero probabilities of finding stars.

One thing I had not expected was that even without rendering a "milky way," the visible stars are noticeably more prevalent closer to the galactic disk. So I also found a best fit great circle and recorded each star's angular distance from that. Plotting those on the z-axis gives:

Distance of stars from galactic disk versus magnitude and color index

You sort of need to move it around to tell what's going on, but basically stars are more likely to be near the disk, and more so if they're brighter and whiter. I didn't even try to quantify this any better, just fudged it.

So I generate 6000 (or however many) stars with color and magnitude selected according to my smoothified histogram. Each star gets a random distance within visibility range (because my initial sample only included stars of a given color close enough to be visible to the naked eye, I can't create any too far away to see without throwing off the distribution) and is either randomly rotated away from the galactic plane or rotated according to a normal distribution, more likely the latter the brighter and whiter it is.

Results shown on the right, alongside plots of the Hipparcos data set on the left (and as shown above).

Plots of empirical and randomly generated star distributions

The results aren't too bad, though that lowest-probability shade in my smootherized histogram is too dark: it should probably be like gray 254.9 or something.

Finally the whole thing gets a random rotation from the galactic plane, and the results might look something like this:

Random starscape

So pretty good! Next step (after tweaking the distance-from-galactic-plane function) would be generating some realistic views from a planet according to axial tilt and times of day and season. And then inventing constellations?

Also maybe the possibility of a perspective from outside a galactic arm? Though how likely is that, if you're looking from a class G or K main sequence star?

I don't know. I think it's cool though.

Source here, requires pygame, numpy, and matplotlib.

Saturday, April 23, 2011

Sight Gag

Had this idea the other day, not sure if it's been done.

Car air freshener hanging from a helmet-mounted bike mirror

Thursday, April 7, 2011

Software Idea

You enter the ingredients list and nutritional information of a food product, like what's printed on the package. The system looks up the nutritional data for each individual ingredient. That information, plus the inequalities implied by the order of the ingredients list, allows it to solve for the relative quantities of each ingredient (giving ranges where an exact amount can't be determined, such as for ingredients with no measured nutritional value).

Basically I want to reverse engineer this here granola.

Sunday, February 13, 2011

31337 is Prime

Did not know that.

Tuesday, January 11, 2011

Unicode Joke?

Am I crazy or does Unicode character 221B look like a Sherlock Holmes pipe?