Sunset Time Series

Posted September 4th, 2011 on Bespoke

Inspired by a reddit image post (which I cannot for the life of me find again), I decided to take a series of photos of the sunset from my parents’ house at Cedar-by-the-Sea, Vancouver Island. I many photos over the course of several hours using a digital camera fixed in position on a tripod.

I thought it would look good to blend the images one into the other, so I wrote a quick python script using the Python Image Library. The script blends consecutive images using linear interpolation. An artistic choice to make was how wide the blended regions should be. I tried everything from relatively thin blending regions:

To almost completely blended images:

In the end, however, I decided that what looked the best was actually to have no blending, but rather sharp boundaries between the images. This actually accentuates the effect I was going for, which was to show the changing light over time. Blending the images together actually lessens the effect, rather than enhancing it as had hoped. I plan to get the finished product printed and framed:

Here’s the code for the script I used (apologies for quick-and-dirtiness):

import sys
from PIL import Image

def imageblend(imdir, numimages = 5, blendwidth=0):
    if not blendwidth%2 == 0:
        raise Exception('blendwidth not even')

    im = Image.open(imdir+"im1.jpg")
    (width, height) = im.size

    for i in range(1, numimages):
        imnum = i+1
        centre = i*width/numimages - 1

        im_i = Image.open(imdir+'im%d.jpg'%(imnum))

        for x in range(blendwidth):
            col_ind = centre - (blendwidth/2) + x +1
            col_box = (col_ind, 0, col_ind+1, height-1)
            col_o = im.copy().crop(col_box)
            col_i = im_i.copy().crop(col_box)
            col = Image.blend(col_o, col_i, float(x)/blendwidth)
            im.paste(col, col_box)

        rest_box = (centre+blendwidth/2+1, 0, width-1, height-1)
        rest = im_i.copy().crop(rest_box)
        im.paste(rest, rest_box)

    im.save(imdir+"im_output.jpg")

def main():
    imdir = sys.argv[1]
    imageblend(imdir)

if __name__=='__main__':
    main()
 

Change I Can Count On

Posted August 14th, 2011 on Bespoke

On my first day of University five years ago, whilst shopping for dorm supplies, I bought this large beer-and-hockey themed piggy bank. Since then, I have deposited any coins smaller than a quarter (ie pennies, nickels and dimes). Today, just 2 weeks shy of moving to the US to start grad school, was time to finally cash in.

2L bottle provided for size-comparison.

Before counting, I wanted to see if I could reasonably estimate how much money there would be. I considered doing a “random sample” approach, counting the value of a small portion and scaling up to the full weight. However, unfortunately the only means at my disposal to weigh the samples was a bathroom scale inteded for weighing people in 0.1kg increments, so I didn’t think this would be accurate enough. Instead I weighed the entire piggy-bank (which came out to an impressive 4.2kg) and made some simple estimations of what the relative proportions of the coins would be as so:

In considering purchases which would result in me receiving small change, I assume that all values of “cents” are equally likely. I further assume that change is almost always given with the minimum number of coins heuristic. Making these two assumptions, and considering the possible values of change between $0.01 and $0.24 (since all other values will be isomorphic with the addition of some number of dollars and quarters), results in the following relative proportions: 25% dimes, 12.5% nickels and 62.5% pennies.

From this, and from considering the weights of each coin (dime = 1.75g, nickel = 3.95g, penny = 2.35g according to Wikipedia) I can estimate the total number of coins thus:

Using the estimated proportions, I therefore get the following estimations for the number of value of each coin type:

Dimes Nickels Pennies
Estimated Number: 437.5 218.75 1093.75
Estimated Proportion: 0.250 0.125 0.625
Estimated Value: $43.75 $10.94 $10.94

Total Estimated Value: $65.63


$65.63! That’s a lot of money! Let’s see how my estimations stack up to reality:

Final counts:

Dimes Nickels Pennies
Counted Number: 462 280 812
Counted Proportion: 0.297 0.180 0.523
Counted Value: $46.20 $14.00 $8.12

Total Counted Value: $68.32

So, the final value was quite close (<5% error), but I think we can put that down to fluke. Obviously, my estimated proportions were quite a bit off, although I was correct in predicting that pennies would be significantly more numerous than dimes, which were in turn significantly more numerous than nickels. Most saliently, the proportion of pennies was significantly less than predicted by my simple a priori method. This can likely be attributed to the tendency of pennies to be discarded or ignored which receiving change. I’m not sure why nickels would be tend to be relatively more numerous relative to dimes than I had predicted. Also interesting is that if I use the Wikipedia-listed weights of the coins multiplied by the real counts, the weight should only be around 3.8kg. Perhaps my scale was inaccurate at such a low weight (as it is designed for weighing humans).

Anyways, it was quite interesting to see how much small-change I had accumulated in 5 years. Tomorrow I’ll be off to the bank with 4kg of coins!


Solid Reasons Humbly Offer’d

Posted July 20th, 2011 on Bespoke

Avast, a post! My first in over a year – Ben has been putting me to shame of late. I was in Dublin this past week visiting my Grandparents. I had a day in town to “see the sights”, but as I’ve been to Dublin several times I wasn’t interested in hitting the standard tourist attractions (Guinness Brewery, Book of Kells, Grafton St. etc) which I have already seen. I did a quick Google search for more obscure Dublin attractions, and happened upon Marsh’s Library, the first public library in Ireland, opened in 1701 by Archbishop Narcissus Marsh and “one of the very few 18th century buildings left in Dublin that is still being used for its original purpose”.

The library is quite a treasure – All of the original shelves and books are on display, dating back to the 18th century. Also on display are the wrought-iron cages in which scholars would be locked with certain valuable tomes. The whole thing reminded me of The Archives at The University of Imre. Most astonishing, the library is still a working library – the majority of the books are still available for perusal by scholars or interested members of the public.

In addition, they had two exhibitions (on The Bible, and on Medicine), with display cases showing books and passages relating to the subject. One piece in the Medical exhibition caught my eye in particular – a glorious Satyre entitled “Solid Reasons Humbly Offer’d to the Consideration of the Publick for Castrating Physicians, Quack-Doctors, &c.” published in 1725.  I have posted this below, with the kind permission of the Marsh’s Library Keepers. What is remarkable is how relevant this piece remains in our era of dishonest “Alternative Medicine” practitioners on the one hand, and iniquitous Medicine-for-Profit on the other (so long as you can look past the distasteful reference to violent colonialism in the first paragraph).

(click to further embiggen)

I think the author makes some good points. Afterall, should not the CEOs of big pharmaceutical companies who put profit ahead of the provision of (easily manufactured) drugs to those who desperately need them “be deem’d guilty of Manslaughter, at least, and suffer Castration as aforsaid?” And should not Alternative Medicine practicioners who, ignoring the lack of evidence for their ministrations and who “thro’ Ignorance, Envy or Neglect, destroys the Patient [they] might otherwise have sav’d” be found “guilty of a Breach of Trust, and that of the highest Nature?” I certainly think so.

What most fascinates me about pieces of this kind, however, is that despite the wide advances in technology we humans have to show for ourselves, nothing ever really seems to change.

Marsh’s Library: http://www.marshlibrary.ie


Climate Change Rap Battle

Posted May 11th, 2011 on Terry

Well, that’s one way to get the word out…
Warning: Strong Language

Make Bananas, Not Bombs

Posted October 14th, 2010 on Terry

A friend of mine posted an interesting fact to Facebook today. Turns out that bananas give off a relatively high level of radiation compared to other foods. Many foods give off small amounts of radiation, but the level for bananas is particularly high, due to the presence of potassium-40. This has given rise to the Banana Equivalent Dose as a measure to compare the radiation found in foods following a nuclear accident. Specifically, the average radiation given off by a banana is 3520 picocuries per kg. A curie is 3.7×1010 decays per second, so 3520 picocuries (pico = 10-12) is a very small amount of radiation.

I wanted to put this number into perspective. Specifically, I wanted to compare the radiation given off by a banana to something more spectacular, like Little Boy, the nuclear bomb dropped on Hiroshima in World War 2. Doing so lead to some interesting and surprising results. Read on…

Disclaimer: I am not a physicist. Please do point out any mistakes I make in the following, it should be very interesting!

First of all, I wanted to know how many bananas it would take to equal the amount of radioactive material in the Hiroshima bomb. According to Wikipedia, Little Boy contained 65kg of Uranium. In reality it was only 80% enriched, but for simplicity I will round up to 100% Uranium-235, bearing in mind that modern nuclear bombs are much, much bigger than was Little Boy. The radioactive decay rate of this much Uranium can be determined by the equation:

Where:

  • A = the radioactivity in decays per second (Becquerel)
  • t1/2 = the half-life of Uranium-235 in seconds which is (703800000 years)*(31556926 seconds/year) = 2.22097645 * 1016 seconds
  • N is the number of Uranium-235 atoms which is (64000 g)/(238.02891 g/mol) = 268.875 mol * 6.022141*1023 mol-1 = 1.6192*1026 molecules

(thank you to Ben Keller for reminding me how to do this)

Therefore, the activity of 65kg of Uranium is:

(note the conversion from Becquerel to Curie)

Comparing this to the 3520 picocuries per kg for a banana gives us the mass of bananas required to equal the radioactivity of one Little Boy:

So approximately 38788 metric tons of banana to equal the radioactivity of one Little Boy. Given that Wikipedia list the average weight of a banana as 125 grams, or 1 eighth of a kilogram, this equals approximately 310 307 272 bananas. That’d feed alot of monkeys.

It may seem like a lot, but according to Wikipedia, the world-wide production of bananas in 2007 was 72.5 million metric tons. This means that the radiation held by the world-wide production of bananas is approximately equivalent to 1870 Hiroshima bombs! Good thing we never get all those bananas in one place.

When I shared these preliminary results with some of my friends, one common train of thought that resulted from our discussion was “I wonder if dropping 38788 metric tons of banana would do as much damage as dropping a Hiroshima-sized nuclear bomb” (This should give you a rather terrifying insight into how my friends and I think).

First of all, how much area would be taken up by that much banana? To figure this our requires knowing the density of banana. Through Google, I found the value of 1.14 g/cm3 mentioned in several places. I couldn’t find the original source for this, but it seems like a reasonable value, given that it is only slightly above the density of water (1.00 g/cm3). Using the density we can determine the volume taken up by 38788 metric tons of banana:

If we assume that these bananas are packed into a sphere with no space in between, we can determine radius by using the equation for the volume of a sphere and solving for radius:

So this would be a sphere with a diameter of 40.6 meters… that’s alot of banana.

But how much damage would this do compared to the nuclear bomb? Well, obviously unlike the the bomb, no nuclear reaction will occur when the bananas hit the ground. But, there will be a large amount of kinetic energy. How much?

According to Wikipedia, Little Boy fell for 47 seconds before hitting the ground. Given that the gravitational acceleration on earth is 9.81 m/s2, this means that our ball of bananas will be travelling approximately 461 m/s when it hits the ground (ignoring drag, which will in reality reduce this speed). Plugging this into the equation for kinetic energy yields:

By comparison, Little Boy had a yield of 63 Terajoules. The nuclear bomb still does far more damage than our giant falling ball of banana.

Food for thought.

What I Think About Educational Technology

Posted May 25th, 2010 on Bespoke

So my friend Andre Malan asked me to fill out a survey about the role of technology in my education. You should too (and if you’re going to you should do so before reading my response below).

It should be noted that my response, though written in a comical tone, is deadly serious:


What you think about Educational Technology

Survey to help me generate ideas and bring data to a talk that I am giving in Victoria. It will be live-streamed so you can see what I do with the data in the end.

On submission of this form you will receive a lot of gratitude and IOU for 2 hugs.

Basic Information

Name: Nicholas FitzGerald

Faculty: Science

Program: Cognitive Systems (Computational Intelligence)

Please Tick the educational technologies that you have used for class (either with or without being asked) at university. *

* paper
* WebCT/Vista/Blackboard
* Course Website
* Google Docs
* Facebook
* Wikis
* Blogs
* Twitter
* School Email
* calculator

Other Please list any others that you have used.

SVN <—- wooooooooo!
Python
Clickers
CS Handin
VPN
Ballpoint Pen
Fountain Pen

Disliked technology

Please list the 3 technologies from above that you disliked the most (including ones from “others”) and explain why you did not like them.

1. WebCT Vista

I COULD answer this question, but to do so thoroughly would far exceed the “approximately 4 minutes” you suggested for filling out this survey. WebCT Vista is by far the worst bit of technology I have even been forced to interact with. I say that as someone who’s used it both as a student and as a TA. Seriously. It. Sucks.
Terrible Stability. Incomprehensible UI. Way too many unnecessary features. No obvious integration with other technologies (would it be too much to ask to get an email reminding me I have an assessment due or that an assignment has been posted?). Seriously. WTF?

2. Clickers

Clickers are the worst example of the kind of crap which has come out of this new movement to make classes more “interactive”. Seriously, I go to class to be taught things, not to sit through a one-hour pop-quiz day after day after day. Here’s an idea: Instead of treating me like an elementary school kid who needs constant supervision and hand-holding to get my HW done, why don’t you give a good lecture, teach me some interesting material, and then give me an exam at the end of the term to make sure I actually took some personal responsibility for my education. Seriously. Kids these days…

3. Ballpoint Pen

These things are crap. You have to press so hard it makes your hand all tired, and by the time you’ve written a paragraph you’ve got a crippling case of carpal tunnel. Everyone thinks they’re so great because they can write under water – but can the write upside down?! No. Seriously. Ballpoint? More like FAILpoint, mirite?

Liked Technology

Please list the 3 technologies from above that you liked the most (including ones from “others”) and explain why you did not like them.

1. SVN / CS handin / ssh / pretty much anything involving commandline

Setting up an SVN server was the best thing I ever did. Makes it so much easier to coordinate my files between the 3 or 4 computers I use. No more messing around with emails etc. Plus, I feel like a bad-ass hacker every time I open a terminal and type “cd ~/school; svn update”. Same with CS handin. LOVE seeing how many tape blocks my homework used. Plus ssh tunneling is like some serious “Matrix” shit. Seriously. Chicks go wild for that kinda thing.

2. HTML + SMTP

Best use of technology for a course I have experienced: Philosophy 441 (Philosophy of Mind) with Dr. Murat Aydede. Simple HTML page with links to necessary PDF readings. Email address to contact for clarifications. Perfection. Doesn’t need to be more complicated than that. KEEP IT SIMPLE, STUPID! Seriously. CSS is for chumps.

3. Fountain Pen

Once you go fountain pen you’ll never return to crappy ballpoints. This thing glides so smooth it’s like writing with melted butter (like the kind you get in that little candle-heated dish when you order crab). Plus I feel like I’m some sort of bad-ass Victorian gentleman every time I whip this thing out. Seriously. Like some serious Mr. Darcy shit up in here.

Your Dream Technology

(most important part of this whole survey…)
So if your professor could use some technology in class that would make school much better what would it be? * this can be something you know of or something made up. Sky is the limit, think outside the box, all that jazz. All I ask is that it is something that you would really, really want to use.

I really can’t think of much. The vast majority of times I’ve had some sort of opinion regarding use of technology in education, it’s usually along the lines of “I really wish this prof would stop messing around with this new-fangled edumacational gizmo and just give a good lecture”. There are a few really good examples of pedagogical tools (AISpace is great), but those are really only useful in “algorithm” type courses. Most of the time they’re just annoying and a poor substitute for a good lecture and a good textbook.

That said, my one wish is for E-readers to reach a stage where they are satisfactory substitutes for hard-copy textbooks in terms of ease-of-use, portability, durability etc.


Proceedings of the Association of Pilish-English Research (PAPER)

Posted April 17th, 2010 on Bespoke

Pursuant to my earlier investigation into Unintentional Pilish occurances, a correspondence with Mike Keith, author of “Not A Wake: A dream embodying (pi)’s digits fully for 10000 decimals“.

Nicholas -

Thanks for the interest in this problem, and for your results.  I’ve also done similar searches in years past with various subsets of PG, but I think you have used a few more GB than I have, and you have found a few examples that I did not find.  My favorite one (which I had already found) is the Captain Cook, since it starts at the beginning of a sentence.

I know that I haven’t seen the one with the 15-letter word, which is nice.

However…I recently found a 9-word example, which I’ve attached as an image file (this book is not available in PG, of course, since it is recent and copyrighted).  This is the current world record.  Somewhat shockingly, I found this one by simply playing with Google for a few minutes using partial-Pilish phrases that I thought would tend to be common.  Nonetheless, it seems clear that searching massive amounts of text mechanically is the way to go for further records.

So, we have the following records (as far as I know):

Starting from the beginning of a sentence: 8 (Capt. Cook)
Not necessarily at the beginning of a sentence: 9

I would, of course, be very interested to hear of new records in either of those categories.

Best Pilish Regards,

Mike Keith

Great! Thanks! Would you mind if I were to post what
you wrote on my blog?

I’m planning to make my little script for searching for these strings
more efficient (via multithreading etc) and maybe I can rig up a
webcrawler so it can be searching continuously. I’ll let you know if
anything  interesting or any new records emerge!

Also I was trying to come up with a way of determining the probability
of finding a Pilish string of length n in a document length m. The
most obvious way is with a Markov Chain, based on probabilities
calculated from the dataset, so I’m planning to give that a try also.

Cheers,
Nicholas

Nicolas -

Sure, no problem – feel free to post what I wrote.

Your 15-letter-word example led me to do another Google search with “straightforward” as the root of a manual search. I eventually found another new record! Look at the 4th post on this page:

http://cs.trains.com/trccs/forums/t/164153.aspx

It begins

David has given you a very straightforward procedure to follow. Since you have not done any CV programming you should…

with the part I have colored in red giving 3.141592653 (10 digits). Interestingly, this was written just a few months ago, in Dec 2009.

Keep me apprised of any new results. It’s great to have another person interested in the search. Would love to see some probability results based on Markov chains.

Cheers,
Mike K


Accidental Pilish: Unintentionally Constrained Writing in English Literature

Posted March 26th, 2010 on Bespoke

Background:

This post is a little late for Pi Day, but it’s never a bad time for discourse related to everyone’s favourite mathematical constant. Twas on Pi Day of this year that I somehow came across this site, which describes the Constrained Writing task of Pilish, in which the length of each word in letters corresponds to the digits of pi:

The first word in this sentence has 3 letters, the next word 1 letter, the next word 4 letters, and so on, following the first fifteen digits of the number π.  A longer example is this poem with ABAB rhyme scheme from Joseph Shipley’s 1960 book Playing With Words:

But a time I spent wandering in gloomy night;

Yon tower, tinkling chimewise, loftily opportune.

Out, up, and together came sudden to Sunday rite,

The one solemnly off to correct plenilune.

Michael Keith, the author of the above website, has created several works in Pilish, including a full-length book covering the first 10,000 digits of pi!

Trying to write under such constraints can feel extremely awkward, but this made me wonder: How often would strings of words adhering to the constraints of Standard Pilish occur unintentionally? Afterall, with the amount of text out there – the sheer rate at which words are being put together by people all over the world every second of every day – it is to be expected that these things should occur with some frequency p > 0. Such is the Law of Large Numbers.

In order to determine this, I would need a large data set. Luckily, such things are readily available. I settled upon the Project Gutenberg ebook catalog – specifically the union of the July 2006 DVD (17,000 books) and the March 2007 Science Fiction Bookshelf CD (most of PG’s Sci-Fi titles). Altogether, this gave me almost 9GB of text (although I later discovered this contained many duplicates, it’s still a hell of alot of words!)

Next I hacked together a small python script which would find, for each file, the longest string of Standard Pilish. Code for this can be checkedout from my SVN repository: http://svn.nfitz.net/pilish

Results:

Somewhat disappointingly, the longest of any Pilish string was 8 digits of pi. The vast majority of books had a longest Pilish string of around 3-5 words. See the histogram below (note the logarithmic scale in the y-axis).

Five books achieved this 8-digit benchmark, listed below, with the section of Pilish text bolded:

Dismounting and throwing the reins over his horse’s head he came to her smiling, sombrero in hand. “Buenas dias, Senorita. Please may I have a drink?”

“Certainly, Mr. Holmes ; help yourself.” She pointed to the olla hanging in the shade of the ramada.

I was weary of the humdrum life of idling on shore or aimless sailing up and down the channel. The admiral’s was a peaceful mission, and no fighting was expected, but I felt a great curiosity to behold new scenes.

And I have a great Objection to firing with powder only amongst People who know not the difference, for by this they would learn to despise fire Arms and think their own Arms superior, and if ever such an Opinion prevailed they would certainly attack you, the Event of which might prove as unfavourable to you as them.

One was part of the empire, the other was enclosed in Poland, and they were separated by Polish territory. They did not help each other, and each was a source of danger for the other. They could only hope to exist by becoming stronger. That has been, for two centuries and a half, a fixed tradition at Berlin with the rulers and the people. They could not help being aggressive, and they worshipped the authority that could make them successful aggressors.

With the most ambitious of the longer poems–”The Four Monarchies”– and one from which her readers of that day probably derived the most satisfaction, we need not feel compelled to linger. To them its charm lay in its usefulness. There were on sinful fancies; no trifling waste of words, but a good, straightforward narrative of things it was well to know, and Tyler’s comment upon it will be echoed by every one who turns the appallingly matter-of-fact pages…

That last one is the only of the five to have one word of double-digit length, thus covering two digits of pi (‘straightforward = 15 letters = ’15′).

Future Work:

I would like to do a similar analysis of an even larger dataset of more modern language. One possibility is a full archive of Wikipedia. I wonder what is the longest string of unintentional Pilish ever produced?

Another interesting question is how the maximum length of Pilish sections in a document scales with the length of the document, and how well this can be modelled with a simple statistical model such as a Markov Chain.


EVENT: Multidisciplinary Undergraduate Research Conference

Posted March 3rd, 2010 on Terry

As part of UBC’s Celebrate Research week, a great event is happening this Saturday at UBC:

MULTIDISCIPLINARY UNDERGRADUATE RESEARCH CONFERENCE (MURC)
Irving K. Barber Learning Centre, Jubilee Room (4th floor)

Saturday March 6, 2010

MURC celebrates the contributions of undergraduate research at UBC.  The conference provides an opportunity for students in any discipline from across campus to present a research project they have been working on while engaging in scholarly debate amongst each other.  Students have the choice of giving an oral, poster or performing/visual arts presentation of their work.  Presentations are judged by graduate students, and prizes are awarded at the end of the conference day during a celebratory gala.  The conference is held every year in March as the kick-off event to UBC’s Celebrate Research Week.

There is a great variety of presentations spanning the full range of subjects from the Humanities and Science, from Literary Criticism, to Molecular Biology, all researched and presented by undergraduates from UBC and UBC-O. A full list of all presentations and posters, and a schedule of the day’s proceedings can be found here: MURC 2010 Program

Shameless Plug! I will be presenting my own research project entitled “ASSESS: Abstractive Summarization System for Evaluative Statement Summarization” at 4pm in room 355!

Hark, A Webcomic!

Posted February 8th, 2010 on Terry

Since I can find no previous mention on Terry, I thought I’d share one of my favourite webcomics. Hark, A Vagrant!, by Canadian Kate Beaton is in many ways to the Humanities what XKCD is to science and engineering (with suitably better illustrations).

In fact, one improvement is that Beaton, a History and Anthropology graduate from Mount Allison University, often accompanies her comics with a blog post explaining the obscure historical references sent up, so while laughing at her witty and hilarious illustrations, you can often learn something, too. Also, in true Terry spirit, she often pens works which deal with the history of science:

So if you’ve got some time after (or while) studying for midterms, why not start from the beginning? Also, post your favourite, if you have one. Here’s one of mine: