Weblog
Thursday, 22 October 2009
-
Troy and B.S. expertise go hand in hand
I am inspired by this wise xkcd comic strip.Troy's Heuristic for English Language Survival: "In regards to literary criticism, smoothly executed B.S. may be considered sufficiently indistinguishable from the real deal -- at least for the purpose of finishing that darn essay in the wee hours of the morning."
(To an extent, this is the humanities equivalent of POGE.)
Thursday, 03 September 2009
-
Probability Sampling
The homework today for AP Statistics was to toss a coin a hundred times and then record the result. Hmm ... what busy work (for a computer).#!/usr/bin/perl -w
# Usage: ./$0 $sample_size $event_name $probability [$event_name$probability ..]
use strict;
my @tmp = @ARGV;
die "Not enough arguments" if scalar(@tmp) < 3;
my $total = shift @tmp;
my %events= @tmp;
my $sum = 0;
for (values %events) {
$sum += $_;
}
die "Sum of probabilities $sum != 1" unless $sum == 1;
my @keys = sort keys(%events);
for(my $count = 1; $count <= $total; $count++) {
my $result = rand;
my $lower = 0;
my $name = undef;
foreach (@keys) {
my $upper = $lower +$events{$_};
if($lower <= $result && $result < $upper) {
$name = $_;
last;
}
else {
$lower = $upper;
}
}
die "Out of range" unless defined $name;
print "${count}: ${name}\n";
}
exit 0;
In all:./randsamp 100 heads 0.5 tails 0.5
The Perl script can work with a variable number of arguments, assuming that the first denotes the sample size and the rest are pairs of event names and probabilities. Of course, the sum of the probabilities must exactly equal 1 or else the scriptdies.
Remember to adjust the shebang line to point to the path of your Perl installation.
Saturday, 23 May 2009
-
It seems that the performance improvements in Ubuntu 9.04 paid off, especially with the new ext4 filesystem.
15 seconds from a cold start on my full installation - here is the bootchart to prove it:
Friday, 22 May 2009
-
Troy vs. Not Troy

This should be self-explanatory. A few days ago, I took a random glimpse at peoples' status messages, and the dichotomy could not be ignored.
QN, at least your misfortune will be humorously immortalized.
Saturday, 09 May 2009
-
Wikipedia Milestone: 3000 Edits

The 3000th edit, I admit, is not a particularly momentous one.
It should have come much earlier, but my Wikipedia involvement has continuously fallen due to real-life commitments...oh well...
Weblog Archives
Don't worry - your calendar is here… to see it in action just click "Save"
above and refresh the page.

