James Tauber's Blog 2007/03
Learning Morse Code
After adding a Braille card pack to Quisition, I started investigating Morse Code and found some interesting information about two different approaches to learning Morse Code that have got me thinking about more general application to learning.
Firstly, some background information on timing. The Paris Standard timing has a dash three times longer than a dot with the gap between atoms equal to a dot, the gap between letters equal to a dash (=3 dots) and the gap between words equal to 7 dots.
Incidentally, with an inter-word gap, this makes PARIS = 50 dots exactly. Some stuff I've read suggested this is why it's called the PARIS standard but the fact the code was agreed upon at a meeting in Paris might have also been part of it.
Now, coming to learning Morse Code, both the methods I've read about agree on one very important thing: they never lengthen the intra-letter gap to make it easier to learn. Doing so apparently gives the learner too much time to think about the letter as an individual sequences of dots and dashes whereas they need to learn the letter a single unit. Remembering the components with the aid of mnemonics (which I otherwise find useful in other domains) actually prevents the learner from achieving fluency.
But after this, the two methods differ. The Farnsworth method starts with very long gaps between letters and slowly reduces them until full speed is achieved.
The Koch method uses full speed gaps between letters from the outset. However, the learner begins with just two letters and new letters are slowly added.
The stuff I've read suggests the Koch method is more effective at getting people to full speed but that either method is still far superior to trying to learn by slowing down individual letters.
Of course, none of this is from my own experience. Perhaps some readers with CW experience might want to comment.
by James Tauber : Created on March 27, 2007 : Last modified March 27, 2007 : 5 comments (permalink)
Django Congratulations
Some congratulations are in order in the Django community.
First of all, congrats to Ned Batchelder and everyone at Tabblo for the acquisition by HP. As far as I know, this is the first acquisition of a company whose product runs on Django.
Secondly, congrats to Adrian, Jacob, James and all the Django developers for the release of Django 0.96. I'm looking forward to switching my Django sites (including Quisition) over to 0.96 as soon as possible (rather than running off the trunk of svn)
by James Tauber : Created on March 23, 2007 : Last modified March 23, 2007 : Categories django : 0 comments (permalink)
Arrow-type Vectors
Part of the Poincaré Project.
When we started to talk about metrics in two or more dimensions I said that "travel in a particular direction at a particular rate" is a kind of vector. This kind of vector can be visualized as an arrow and, with vector addition defined in terms of placing the tail of one arrow at the head of the other, we find that these arrow-type vectors form a linear space.
The first diagram shows the way addition is defined. The additive identity (the zero-vector) can then just be thought of as the point in the second diagram. The third diagram shows how inverse of an arrow-type vector falls naturally out of the definition of addition. And finally, the fourth diagram shows scaling. From the axioms we defined for linear spaces we know that v + v = 2v for all linear spaces because v = 1v so v + v = 1v + 1v = (1+1)v = 2v.
Visualizing vectors as arrows is common in introductory approaches to vectors in both mathematics and physics. Displacement, velocity, acceleration, force, etc are often described in these terms. However, there are other physical quantities that, while able to be modeled as objects in linear spaces, are best visualized as something other than arrows. In the next Poincaré Project post, I'll introduce this new type of object that I'll initially call a stack-type vector.
UPDATE: next post
by James Tauber : Created on March 21, 2007 : Last modified Aug. 9, 2007 : Categories poincare_project : 2 comments (permalink)
Python Primality Regex
Via Simon Willison I discovered this wonderful method of testing primality with a regex by Abigail by way of Neil Kandalgaonkar.
Of course, I couldn't resist porting it to Python, so here it is:
import re def is_prime(num): return not re.match(r"^1?$|^(11+?)\1+$", "1" * num)
although the magic is all in the regex which is copied verbatim from the Perl.
Firstly, the num is turned into a string of 1s so 0 = "", 1 = "1", 2 = "11, 3 = "111" and so on.
The ^1?$ just matches the 0 or 1 case to ensure they don't come up prime. The main part of the regex is the ^(11+?)\1+$.
It basically says match a group of 2 or more 1s repeated one or more times. If the string matches a group of 2 1s repeated one or more times, it's divisible by 2. If the string matches a group of 3 1s repeated one or more times, it's divisible by 3 and so on.
So this regex basically tries to see if the number is divisible by 2, then 3, then 4, etc., stopping with a match once a divisor is found.
And you can find what the lowest divisor was: it's simply the length of the first match group.
UPDATE: I've added Abigail to the credits, per Neil's comment below.
UPDATE: I've removed the phrase "regular expression" as, as pointed out by a commenter on reddit, it's not actually a regular expression.
by James Tauber : Created on March 18, 2007 : Last modified March 19, 2007 : Categories python mathematics : 8 comments (permalink)
Python Software Foundation Accepted into Google Summer of Code
Not really any surprise, but I'm still delighted to announce that the Python Software Foundation has been accepted into Google's Summer of Code for 2007.
If you're interested in being a mentor, it's not too late: see my previous post How to be a Python Mentor in the Google Summer of Code.
If you're interested in being a student, we'd love to have you! Check out http://wiki.python.org/moin/SummerOfCode for project ideas.
by James Tauber : Created on March 15, 2007 : Last modified March 15, 2007 : Categories python summer_of_code : 1 comment (permalink)
Generating the Hex Digits of Pi
Seeing as it's Pi Day (3/14) I thought I'd post the little Python script I wrote at PyCon implementing Simon Plouffe's remarkable formula for pi in hex.
def pi():
N = 0
n, d = 0, 1
while True:
xn = (120*N**2 + 151*N + 47)
xd = (512*N**4 + 1024*N**3 + 712*N**2 + 194*N + 15)
n = ((16 * n * xd) + (xn * d)) % (d * xd)
d *= xd
yield 16 * n // d
N += 1
For example, the following code displays the first 2000 digits.
pi_gen = pi()
import sys
sys.stdout.write("pi = 3.")
for i in range(2000):
sys.stdout.write("0123456789ABCDEF"[pi_gen.next()])
sys.stdout.write("\n")
You'll notice that pi in hex begins 3.24 so perhaps I should have waited another 10 days :-)
And if you're wondering why the hex digit after the point is higher that the decimal equivalent, remember that after the point, hex digits are worth less than their decimal equivalents.
by James Tauber : Created on March 14, 2007 : Last modified March 14, 2007 : Categories python mathematics : 5 comments (permalink)
How to be a Python Mentor in the Google Summer of Code
This has been announced elsewhere but it shouldn't hurt to mention it here to get on some Python Planets, etc.
If you would like to be a mentor on a Python-related project for Google's Summer of Code this year, here is what you need to do RIGHT AWAY:
- add your name to the Summer of Code Mentors page on the Python wiki
- email me with your name and Google Account (you need a Google Account to participate—a Gmail account is fine)
- join the soc2007-mentors mailing list
If you can't mentor but still have some project ideas, feel free to just join the mailing list for discussion.
by James Tauber : Created on March 11, 2007 : Last modified March 11, 2007 : Categories python summer_of_code : 0 comments (permalink)
Interfaces versus Abstract Base Classes in Python
In his Python 3000 keynote, Guido talked about having marker interfaces to make more explicit notions like "list-like" and "file-like". As I understood it, the idea is to be able to test that an object is "list-like" or "file-like" explicitly rather than arbitrarily pick some attribute on the object to test for as the diagnostic.
What confused me at the time was that Guido was calling this feature "Abstract Base Classes".
To me, this conflates inheritance with polymorphism. Aren't abstract base classes fundamentally about inheritance of (partial) implementation? But surely this isn't what Guido is talking about—he's purely talking about the interchangeability of objects (i.e. polymorphism).
So isn't the term "abstract base class" inappropriate and potentially misleading?
by James Tauber : Created on March 4, 2007 : Last modified March 4, 2007 : Categories python : 9 comments (permalink)
The First 100 Quisition Users
A couple of days ago, the number of user accounts on my flashcard site, Quisition, hit 100.
Of those 100 accounts, only 89 were activated. That means 11 people either entered an incorrect email address or never responded to the activation email.
Of those 89, only 72 created a deck for testing and of those 72, only 57 learnt any cards with that deck.
All of this is understandable given the number of people that came to just try it out or see how I'd used Django in a particular way.
The only statistic that really disappoints me is that, of the 57 that started learning cards, only 1 user hasn't currently got any overdue cards to review. And that user is yours truly, so really my user retention is currently 0%.
Oh well, I'll still continue to improve it. It's been a chance for me to learn Django and I have now learnt all the chemical symbols (and will continue to review them with Quisition).
If anyone has an suggestions on how to improve Quisition, email me or leave a comment here.
by James Tauber : Created on March 3, 2007 : Last modified March 3, 2007 : Categories quisition web_marketing : 8 comments (permalink)
Linear Spaces
Part of the Poincaré Project.
To understand the metric more we need to talk about vectors but to understand vectors, at least in our context, we need to talk about linear spaces.
Remember right at the start of the Poincaré Project, we talked about adding structure to sets. Like most mathematical objects with "space" in their name, a linear space is a set of objects with a particular structure added to the set consisting of relationships between and operations on the objects.
Informally, a linear space adds just enough structure to a set that the elements can be added and scaled. And that's the principal way you should think about them here.
More formally, addition of the elements must be defined in a way that is associative and commutative and such that there exists an identity element and, for each element, an inverse. This makes linear spaces commutative groups.
Further more, there is a notion of scalar multiplication (for our purposes by a real number) such that (if a and b are real numbers and u and v elements of the linear space):
a ( u + v ) = a u + a v
(a + b) v = a v + b v
a (b v) = (ab) v
1 v = v
It is very important to note what the structure of linear spaces by itself does not provide. There is no notion of the length of an element or the angle between two elements. Neither is it possible to multiply elements by each other. They can just be added and scaled.
Often linear spaces are called "vector spaces" and their elements "vectors" but, as we will soon see, it's useful for our purposes to keep "vector" to a more narrow sense.
UPDATE: next post
by James Tauber : Created on Feb. 28, 2007 : Last modified Feb. 28, 2007 : Categories poincare_project : 0 comments (permalink)