Valid CSS! Valid XHTML 1.0 Transitional! Powered by Blogger

Marxism at large

Marxism as I understand it is fundamentally about everyone working together as a team for the good of all. So are the Marxist society going to clean up after themselves and remove the posters (and glue) that are up all on bus stops around the university advertising some Marxism expo that's going on?

I hate littering and stuff. Why are people so stupid? Can't they figure out that they live here too, and that if we keep the place a bit clean and tidy it's nicer for everyone.

I'm sure it all has to do with people's innate instincts to mark territory and show social status etc. etc. to which my reply is "Grow up you little prick and put your rubbish in the bin".

Posted on Wednesday, July 15, 2009 at 9:10 AM

Polite Notice

I just recieved an e-mail from a restaurant at the University where I work. It started with the dread phrase "Polite Notice".

Where the hell did this thing of putting "Polite Notice" everywhere come from! I don't even know what people mean when they use it. Does it mean that this is a polite notice but an impolite notice may follow? Does it mean that I should understand that the note was meant to be polite even if it seems rude?

What I am slightly more sure of is the etymology of the term. As I understand it (and this is only backed up by personal observation) the original use of the phrase was on signs such as "Polite Notice: No Parking" which were made to look almost identical to the signs "Police Notice: No Parking" apart from that change of a single letter. I guess that this was done in the hope that a busy motorist would not notice this difference and would be dissuaded from parking and blocking someones drive/garage.

Somehow this usage has seeped in to common parlance and I think it has lodged in peoples minds as a phrase, like "yours sincerely" at the end of a letter, that doesn't really have any specific meaning any more but is just a formal part of the structure of the communication. So "polite notice" is "something that you put before a sign/notice". This thoughtless use of language annoys me disproportionately.

I think I will make up a sign to put around the place. It will say "Polite Notice: Stop putting 'Polite Notice' on signs",

jk

Posted on Thursday, March 12, 2009 at 10:57 AM

Computer Vision Forum

I've just found a new computer vision forum on the web.

Oh yes - it's my new website. That's how I found it ;)

Posted on Tuesday, March 10, 2009 at 11:04 PM

Awesome Pictures

I just found this gallery of images of the super-kamiokande neutrino detector in Japan.

The pictures are pretty breathtaking, especially when you realise that each of those little domes is a hand blown piece of glass...

Posted on Wednesday, August 06, 2008 at 12:54 PM

Fire alarms

Just had to leave Starbucks due to a fire alarm :(. Still they have promised free re-fills for those of us forced to up and leave our seats!

Also I got my brand new gransfors bruks Small Forest axe, my lapplander folding saw and my fallkniven (spelling?) dry whetstone this morning (my Japanese sandstone is good but messy and not so portable...)

And just to top it all off I made some delicious double chocolate muffins this morning, although most of them have gone to Holly's meeting so I only got to try one (but I think I will make some more this evening!)

Pattern for multi threading matrix operations

When using numpy efficiently you often end up using broadcasting operations on large matrices to e.g. calculate a difference over all possible combinations of feature vectors and then take the minimum.

This kind of thing is very CPU efficient compared to looping and calculating in Python as all the looping etc. is handled by numpy's internal libraries but it can be memory innefficient (I keep on running out of RAM on our server which has 32Gb of the stuff...) and also as a monolithic operation doesn't make use of multiple threads (it also has 16 cores so I want to use them all).

Anyway I discovered the following usage pattern for easily splitting up a big matrix operation in to smaller chunks so it can fit in to memory and parallelising the operation (which is one of the big benefits of having all the heavy lifting done in numpy's C code rather than in GIL encumbered python)

First off you decide how you are going to split things up. So something like this:

cs = 10

Means I am going to split things up in to 10 column chunks for processing.

Then define a functor or lambda expression that operates on the data you want to process taking a start index as the parameter:

f = lambda x : log(A[x:x+cs] + B[newaxis])**2

Note that this is baking A, B and cs in to the expression - you could wrap things up in a functor and then specify A, B and cs in your final expression, but I can't be bothered.

finally you run parallel_map on your function and stitch together the results:

nt = 10
res = vstack(parallel_map(f,range(0,len(A),cs), nt))

This would split it over 10 threads. If you just want the parallelism speed up you set cs = len(A)/nt. If you want memory and speed optimisation you set nt and cs independently. If (for memory reasons) you want to further subdivide your problem you can use map within your lambda function to split up the indexing of B

Finally, vstack will do something wierd to your results if you are iterating over a single item each time so you may need to do something like this:

f = lambda x : [log(A[x] + B[newaxis])**2]

so you get a bunch of single entry lists which vstack will stack correctly.

So there you go - happy and efficient processing!

Posted on Friday, June 27, 2008 at 11:31 AM

See, I can organise a piss up in a brewery...

I've organised for me and my dad to go on a Hog's back Tour on Saturday as a joint Father's day / Birth day present

You get generous sampling and a souvenir glass to keep!

And I will get to use my new BBQ show off my new guitar and drum machine and my new Bass Strings (as used by Steve Harris - although they are really heavy and have put the relief and action on my Bass all out of whack) when the family come over for a birthday BBQ.

It will be great!

Autoreloader for python

I was discussing ways to get python to automatically reload modules (useful when using matplotlib to try out algorithms and stuff) and came up with the following:

class Autoreloader:
    def __init__(self,moduleName,path = None):
        self._moduleName = moduleName
        self._path = path
        
    def __getattr__(self,attr):
        import inspect
        import imp
        import sys
        sys.path.append(self._path)
        _module = imp.load_module(self._moduleName,*imp.find_module(self._moduleName))
        sys.path.remove(self._path)
        if attr == "__members__":
            return [a[0] for a in inspect.getmembers(_module,inspect.isfunction)]
        else:
            return _module.__dict__[attr]

Then instead of doing

    import my_module

you do

    my_module = Autoreloader("my_module")

After that you can add a function to my_module.py, go back to ipython, and type my_module.<TAB> and your function will magically appear! To change the function just hit ctrl-S in your text editor and the next time you run the function it will pick up the changes.

This does incur a performance hit and this is version 0.1 I'm sure it can be improved...

Posted on Thursday, May 22, 2008 at 3:42 PM

Thoughts on statistics

After reading some Good Math Bad Math (which should of course be Good Maths Bad Maths) on statistics, and while doing quite a bit of stats in my current research, I decided to try and write up a few interesting thoughts I have had on the subject. As ever my thoughts are a little disorganised so I will probably come back and edit this a few times...

It seems to me that statistics is all about the partitioning of sets of outcomes based on some property they have.For example take the tossing of a coin. By saying that a coin has a 50/50 chance of coming up heads or tails, what we are saying is that there are a large number of outcomes to the action of flipping a coin (with each "outcome" here meaning a possible trajectory for the coin) which we can partition in to two sets, one set having the property that the coin will end up heads up and the other that it will end up tails up.

So the Frequentist / Bayesian argument then becomes one of whether you approach this situation in a top down or a bottom up manner.

The Frequentist then is bottom up says that the partition between sets does actually exist and therefore we can determine it's position by exploring the space (in this case by tossing the coin repeatedly).

The Bayesian on the other hand says that the partition only exists because we lack the information to fully describe the path of the coin and so in the absence of further knowledge the best we can do is say that all paths are equal and partition the space in two.

Fundamentally the two are the same. Maybe I can make myself clearer by looking at the biassed coin question. The Frequentist will say that the chance of the coin coming up heads is not 50/50 and the bayesian will say that it is. The problem is not in the model however, the problem is that they are talking about different experiments!

The Frequentist with his bottom up partitioning approach starts with the biassed coin, looks at the possible paths and looks where the partition should be drawn. The only thing he can say is that the partition is not equal. Repeated tosses of the coin would show this to be true.

The Bayesian on the other hand has a top down approach and so he looks first at the possible number of biassed coins he could get and then at the possible number of biasses. He sees the total number of outcomes (coin bias + coin trajectory) as being equal that end in heads and that end in tails.

So if a Frequentist considers the experiment to be "You are given a biassed coin and toss it" rather than "you toss this particular biassed coin" he too comes to the same conclusion as the Bayesian. Whereas if the Bayesian were given a specific biassed coin and asked to come up with a statistical model of how it come up heads or tails, he would toss it a load of times, determine the bias and then put that in to his model as a prior

"Ah" you say. "That's all well and good, so long as you consider a totally mechanistic view of the universe where true randomness does not exist. Once you allow for true randomness the two views deviate again."

Well, that's only true if you allow for true randomness. And in some future post I will show that we have no reason to believe in true randomness at all.

Posted on Wednesday, April 16, 2008 at 5:54 PM