Saturday, May 31, 2008

Friday, May 09, 2008

Reproduce like a Dandelion

Inspired by Cory Doctorow's latest Locus column, Think Like a Dandelion.

Reproduce like a dandelion!
Spread your seed to the internet wind!
Let it take hold where it may;
Let ev'ry shy patch of mind peeking through
Each crack and crevice
Offer it the briefest solace
That it may take root
And bloom
Throwing your seed further and further afield
Upon the wind until,
Like the dandelion,
Your offspring has taken root
In every corner of the globe!

Trying to Compile from a Buggy Codebase

In tribute to Robert Frost's Stopping by Woods on a Snowy Evening

Trying to Compile from a Buggy Codebase

Whose errored code this is, I know:
We fired him three years ago.
But still his bug-filled code is here,
And makes the server run so slow.

My chest starts to constrict with fear,
And my eyes begin to tear—
And my knees will even shake!—
With each bug report I hear.

Why do I permit this ache,
This long-gone other man's mistake,
To cause me now to moan and weep?
'Cause ev'ry night the thing will break!

Each change I make breaks something deep.
But I have unit tests to keep
Me sane these days before I sleep,
Yes, sane these days before I sleep.

Saturday, April 12, 2008

Demonstrating Monty Hall in Python

There was a recent article on the Monty Hall problem in the New York Times blog TiernyLab.

The problem is this: You're on a game show, and there are three doors you may choose from. One door contains a car (or something else that's desirable) and the other two doors contain goats (or something else that's undesirable). After you pick your first door (this is the important part), the host must open another door and show you a goat. You then may choose whether to stick with your original choice or switch doors.

Should you switch doors?

Most people's response is "it doesn't matter, because the car could be behind either door, so it's the same as if I'd just been given the choice of the two doors, so it's 50-50". But that's not true, and here's why:

Monty's Constraint, as I call it, changes the odds. When you first selected a door, you had a 1/3 chance of choosing the car, and you had a 2/3 chance of choosing a goat. If you were to switch at this point, before Monty (the host) opens another door, then your odds would still be the same.

But, because Monty has to choose a door with a goat behind it to show you, there are two possible scenarios. First, if you picked the car (a 1/3 probability), then Monty can show you either of the two remaining doors as he pleases. But, if you picked a goat (2/3 probability), then the door he doesn't pick must contain the car.

Therefore, your odds of winning if you switch are 2/3 (because those are the odds that you originally picked a goat) and your odds of winning if you stay are 1/3 (the original odds that you picked the car).

Don't believe me? Steve didn't, at first. So I wrote a little program to prove it. It's in Python, so you shouldn't have any trouble understanding it, even if you're not a programmer.

Link: Python interpretor.

The Code:

import random

switchWins = 0
stayWins = 0

CAR = 1
GOAT = 0

for i in range(0,10000):

# set up doors. the set of doors is an array of two 0s and one 1.
# The 1 represents the car.
# start off with an empty set
doors = [GOAT, GOAT, GOAT]

# choose a door to have a car
carDoor = random.randint(0,2)

doors[carDoor] = CAR


# choose door (player)
playerDoor = 1

# choose door (monty). We use this to ensure monty
# randomly chooses a goat door.
montyDoor = random.randint(0,2)

# if the door monty picks has a car, or if the door he picks is
# the player's door, we have to pick again.
while doors[montyDoor] == CAR or montyDoor == playerDoor:

montyDoor = random.randint(0,2)

# There are only two doors left. If the player's door doesn't have
# a car, then the player would win by switching, so count it

if doors[playerDoor] != CAR:
switchWins += 1

# Conversely, if the player's door does have a car, the player
# would win by staying, so count that
if doors[playerDoor] == CAR:
stayWins += 1

print switchWins, stayWins

Saturday, April 05, 2008

A sandbox for real life (a ramble)

Every so often I read something that proposes some change that will have some sort of desirable effect. (Being an anarchist, I believe this to be true about anarchy.) But, we live in a situation where it is not only impractical to experiment on every idea that comes our way, it would arguably be immoral. Communism, for example, at least as practiced in Soviet Russia, in which the suffering of the poor was worsened by tyranny.

Now, we can run simulations and create models, but these all suffer from simplification because we have to choose what to leave out of the model or simulation in order to make it generate results in a reasonable amount of time.

So, I wish we had what programmers call a 'sandbox' for real life; a place where we could test theories out in conditions as close to the real world as possible, preferably identical. A place where we could get the results of a hundred years in a few days (or less!).

Of course, that does make me wonder: is the suffering of the sandbox any less than real suffering? Does the fact that it all gets washed away when you're done cleanse the wrongs?

Anyway, enough ramble for now.

Sunday, March 30, 2008

Flight of the Bumblekey

[INT. CAR. GEOFF is DRIVING.]

[ALGERNON the pentapede JUMPS onto GEOFF'S LEG and begins ATTACKING GEOFF'S KEYS]

GEOFF: Algernon, what are you doing?

ALGERNON: I'm practicing to join BrightonMusic.

GEOFF: What?

ALGERNON: You need someone to play the keys.

[ALGERNON ATTACKS the KEYS some more]

GEOFF: Why in the world would we need a key player?

ALGERNON: There are lots of songs that need keys.

GEOFF: Like what?

ALGERNON: "The Flight of the Bumblekey!"

Folk Music from Around the World (BrightonMusic)

April 13, 2008 45:30pmFolk Music from Around the World– at Brighton First Presbyterian Chruch, 510 S 27th Ave, Brighton, CO 80601
The BrightonMusic Choir and Orchestra will present "Folk Music from Around the World". Admission is free.

This hCalendar event brought to you by the hCalendar Creator.




View Larger Map

Sunday, March 23, 2008

Whither the firsts goeth...

I found this recently on a piece of (viola) sheet music...

I disagree with this bowing, but whither the firsts goeth, so must I.


It about sums it up.

Easter Story on One Step from Sunday

Ok, I've decided to start promoting the scribblings I make on One Step from Sunday here. The latest is Easter Story, which is about the true origin of Easter.

Saturday, March 15, 2008

The City Born Great - How Long 'Til Black Future Month?

The second story in N. K. Jemisin's anthology How Long 'Til Black Future Month? , "The City Born Great," is an exciting ta...