Weblog
Friday, 20 November 2009
-
Gluing Balsa
Minimizing Weight Gain While Maximizing Strength When Gluing Balsa
I remember Wright Stuff from middle school...
Monday, 09 November 2009
-
Bug?
I discovered today, interestingly enough, that the exponentiation operator ("^") in the TI-83/84+ calculator series is actually left-associative: the expressiona^b^c^din fact evaluates to(((a^b)^c)^d), orabcd. This is also the case with the older TI-36X II scientific calculator.
Ordinarily, one would expect the operator to be right-associative:a^b^c^devaluates to(a^(b^(c^d))), orabcd, in common programming languages.
IMHO, this discrepancy could be considered a bug, but apparently the behavior has always varied from model to model.
Still, a part of me is left wondering how that little detail managed to escape my attention for several years.
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:
Weblog Archives
Don't worry - your calendar is here… to see it in action just click "Save"
above and refresh the page.

