Tuesday, August 31, 2010

Life by Numbers

This is a bit of a lazy 'en. I basically print-screened a load of stuff off a couple of stats sites. For some reason.

It basically comes down to this - I'm very tactless open about what information and details about my life I share. I'm also oddly enigmatic about other areas of my life, so it all kinda balances out.


Twoolr

Relatively new, and still in beta, Twitter analyser. Like most of these sites, there's a limit to how far back it can collect data for analysis. So these details are true of, I think, my last 3,800 or so tweets. I'm currently on 5,600+, so it's not extremely representative. But nonetheless.

My tweeting activities over the course of a day


Guess when I sleep..? There's also this site - SleepingTime.org - that basically does the same: works out when you're most likely to be asleep. Technology, eh?

And over the course of a week
Apparently I'm a long weekend tweeter.
And over the course of the last month. Note the dips when I was revising (see, I was good) and the massive compensating spikes shortly after.
Most used tags cloud. Most of the most used ones are 'twitter memes'. I may have gone over the top with the zombie proverbs. The one I'm most proud of
Many hands make light snacks.
Moving on.. Other random facts:
I tweet a link every 15.3 tweets
On average, my tweets contain 11.15 words and 0.2 hash-tags
My tweets distribution - 37.7% replies, 2.77% RTs, 0.29% FFs
I interact most with: @aaangst, @abooth202, @Aerliss, @benjirino, @missgiggly, @PkmnTrainerJ, @SallyBembridge and @shinelikestars6

And here are the people who think I'm interesting/funny enough to retweet:
A lot of these people I don't know. Some surprises. And if any of you are reading, thank you :]


Another site I look at from time to time is TwitterAnalyzer. But that gives much the same information (maybe less) in a less aesthetically pleasing interface. It also seems to be borked at the moment. But there you go.

There's also this - Twitter Grader. It doesn't give anything particularly insightful, but my 'grade' is 81/100. Which is nice.

And statistics aside, I'm sure there's a lot one could get from just reading my tweets - all publicly viewable. I mean, I dread to think what a mind such as Sherlock Holmes could deduce about me from a handful of tweets. But lucky, he doesn't exist.


Daytum

At some point, I decided it's be a good idea to use this site to keep track of my consumptions and sleep. I checked, and the records go back to March 15th 2010. So about 170 days' worth.

Sleep
It averages at about 8 hours. I think. Check out them there dips. It's a wonder I managed to function properly!

Drinks
Measured in servings. Yeah, I drink a lot of tea :p In fact, over the last 41 days,
It averages about 3.5 cups a day. Oh, and just ignore the whiskey count, eh? ;)

If you're really that interested (weirdo), you can find all these stats here.

I'm sure if I were into exercising of any sort or trying to lose weight (if I needed to) or anything like that, I'd be tracking that too. But as it is, I'm not. So there isn't really anywhere you can find that sort of thing without outright asking me.

Or since I'm feeling generous - approximately.


FourSquare

The location-based 'game' that also doubles as a nifty way to stalk* keep track of where I am or have been, with varying degrees of certainty - For example, it says I'm in Brampton right now (last place I checked-in) when I'm really in Wath.

You can find actual stats here. Some 'interesting' ones:
I check in most on Fridays and on Saturdays [but mostly on the latter days]
I visit Parkgate - Costa Coffee most often (~3x a week).
On average, I check-in 3.3 times while out
I'm currently Mayor of 14 places, of which four are coffee shops**

So one of the sites that's good for plotting FourSquare check-ins on a map is "WeePlaces" - which, unfortunately, is also being a worthless piece of crap right now. Just my luck :/


So. Until I start tracking everything I watch on TV, every film I watch, every book I read and anything else that it would be sane to record - you'll just have to go without knowing. Or ask, if you're that desperate.

And for your last random fact - my 3 most listened to artists are Pink Floyd, Tool and Karnivool.

Rock on.


Oatzy.


*For the life of me, I can't imagine why anyone would want to stalk me. But you never know.
** ..And I will also happily do weddings (Y)

Monday, August 30, 2010

Miscellaneous Crap

More Sex and Lesbians

Dimensional analysis is a hell of a thing. You can come up with all sorts of dubious 'statistics'. Here's an example from XKCD
I looked up the population density of my area - South Yorkshire & Humberside = 340 people/km^2 - ran the numbers and got a radius of 452m. So on a map, that looks something like this

Now straight away, you see that on account of the relatively low population density around my house, this value probably isn't that accurate. There are several other assumptions and problems as well. But I'm not going to go into that.


As for the lesbians, it works out pretty much the same. The only difference is that you adjust the population size.

According to Wikipedia, an estimated 6.76% of the female population of UK are lesbian - ~3.38% of the total population. And that equates to a radius increase of about x5.4. This leads to a radius of 2.46km (~1.5 miles in old money).

And that looks like this

Again, this ignores things like the low population density of the area, the dubious lesbian population estimate, etc. and assumes that the average duration and frequency of lesbian sex about matches the general average, etc. And time dependency! But, again, I'm not going to go into all the details of that.

Why did I work out the numbers for lesbians? Why not? And that way I'm not just flat out copying XKCD. Plus I've got a quota to meet*


Will I Get a Girlfriend at University?

So there are 18,480 undergraduate students at Sheffield. If you adjust for gender, sexuality and relationship status (assuming 50% are in a relationship) that number becomes 4,359.

But obviously that doesn't account for preferences like attractiveness, personality, intelligence, etc. and whether they'd be interested in me.

Now this guy, in the article "Why I Will Never Have A Girlfriend" goes a little further, using normal distributions and such to adjust for the above (a man after my own heart). So if I assume that I can apply the same ratios as he does, that number goes down to...

*drumroll*

2.5

Yeah. It doesn't look good. But maths be damned! Besides, this estimating isn't an exact science.


LD50

The LD50 of a given chemical is the dose that will killed ~50% of a population, or equivalently, that has a 50% chance of killing you. Usually based on dose per kilogram of body mass, and varies depending on animal, due to varying metabolic rates. So we can do some fun things with these values.

Let's assume a person weighing 14st. To find for your own weight, divide by 14 and times by your weight in stones.

Note that the quantities would have to be consumed within the half-life of the chemical in question.

Caffeine - 192mg/kg = 41 cups of coffee

Alcohol - 10.6g/kg = 118 units = 19.7 bottles of wine

Theobromine - 488mg/kg (estimated) = 3.1kg of dark chocolate.

Now, Hotel Chocolat sell 500g slabs of chocolate - so you'd only have to eat six of those to become seriously, and potentially fatally, ill. That being said, it'd take a strong man (or woman) to eat six of those in a day or less! And my hat goes off to anyone who tries.

For a 20kg dog (a small female Labrador, for example), it'd only take 240g of dark chocolate. Which is why you shouldn't let dogs (or any small animals) have chocolate. But you already knew that.

I also remember reading somewhere (but can't remember where) that for a small bird it'd only take an M&M's worth of chocolate. So yeah, if you're looking for a new hobby... **


Ireland and Alcohol

The average alcohol consumption in Ireland (per person per year) is equivalent to 13.69 litres of pure alcohol (100% vol.). That's equivalent to 1,369 units per year, or 26.3 units per week.

And just for fun - what that means is Irish people, on average, drink the equivalent of 11 pints of Guinness a week.

[Yeah, I went there.]

Oh, and contrary to popular belief, Ireland doesn't consume the highest amount of alcohol in Europe (per person per year) - at 15 litres, Luxemburg does!

The UK only consumes a comparatively pitiful 12 litres, in case you were wondering.


At What Times Do the Hands of a Clock Meet?

I'm not going to go through the derivation, but basically you work out each hand's angular speed, equate and rearrange.

The equation looks like this

Where, H is hours - 0 to 11 - and the minute fraction is rounded to the nearest whole number.

So, the times are - 0:00, 1:05, 2:11, 3:16, 4:22, 5:27, 6:33, etc.

You could include the seconds hand as well, but that just complicates things. Well, not really. But... lazy :]



When Will I catch Up to @PkmnTrainerJ?

That is, when will I match his number of tweets? This is something I worked out before, reproduced here for the shear hell of it.

So first of all we have to assume that our rates of tweeting can be considered approximately constant when averaged over some period of time. So say my rate is r_1 and his is r_2. If we assume that I post more tweets a day than him, then my relative speed of tweeting is

(If his rate is greater than mine, then I'll 'never' catch up.)

You then take the difference between my tweets and his - i.e. how much I have to catch up by. Call that d.

So then rate = tweets/time, or, time = tweets/rate

If rate is in tweets per day, then time is in days.

I wrote a program for this, that you can look at here, if you're so inclined. And according to that program, I should catch up in 437 days, or on 11th October 2011.

NB, Due to difficulty in calculating the rates and the variability of rates over time, the results aren't particularly exact. Especially for long periods of time like above.


Houses of Cards

How many cards, c, does it take to build a house of cards n levels high?

If you want to know how that's worked out, feel free to ask.

From that, we can rearrange to get the highest 'house' we can build with c cards

So for a standard pack of 52 cards, the highest house you can build is 5 levels high (with 12 cards left over). To Build a 6 level house you'd need 5 more cards.



Oatzy.



* I don't actually have a quota. But I've definitely set a personal record for most uses of the word 'lesbian' in one post... I'll stop now.
** Please don't poison small birds.

Sunday, August 29, 2010

Did Twilight Cause the Recession?

Short answer - Of course not! Don't be silly.

But it's worth looking at anyway. First of all, here's the 'proof' I tweeted:

So there are a few things going on here,


Correlation Does Not Imply Causation

If you've ever visited Slashdot or the likes, whenever there's a report showing a 'link' between two phenomena, there will be at least one comment declaring "correlation != causation".

In other words, just because two sets of data seem to show a link - even a "statistically significant" one - doesn't mean one of the variables caused the other.

In such cases, it's important to look at what's going on in more detail.

For example, say the link is "people who watch more than two hours of TV a day, on average, die ten years younger than those who don't" - watching TV in and of itself doesn't shorten you life span. But people who watch a lot of TV are more likely to have generally unhealthy lifestyles - i.e. exercise less, eat more junk food.

That's more likely, but not necessarily. This also leads on to the next point,


Cause and Effect

So say you have your two variables that seem to correlate in a statistically significant way.

If we pretend the Twilight graph shows a 'significant correlation', did Twilight cause the recession? Seems highly unlikely.

Or, is it more likely that the recession led to a rise in the popularity of books (in general). Or did more people turn to fantasy as an escape from the harsh reality of the recession-ravaged world? Or is it just plain old coincidence?

Similarly, with the TV example you find that in fact both are most likely effects of the same thing - i.e. an unhealthy lifestyle. Neither caused the other.

And because of these first two reasons, always be wary of reported 'links' between things in the news (and in tabloids especially). It's not that hard to mislead or be mislead by statistics*.


Confirmation Bias

Based on our pre-existing biases, when presented with a piece of evidence, we tend to ignore things that don't support our theory/opinion and clutch at the things that do.

This is why opposing sides of a debate can use the same piece of research to support opposing claims.

And for anyone who doesn't like Twilight (and would like a link to be true), it's more likely they're going to see some sort of correlation in the graph, than someone who is a massive fan.

And this can mean ignoring the fact that it's a fairly poor match. I mean the overall shapes, if smoothed out, just about match up,

But then there's those massive spikes. And if you look at the details of the curves closely, they are actually quite different. Especially in the middle.

So depending on your own bias, you can look at that graph and argue for your opinion in either direction. Though anyone with any sense knows any match in this case is all just a weird coincidence.


And finally,


I 'Gamed' the Results

I started out trying to find something to blame Justin Bieber for. He became popular around the start of this year, so the thought was - what negative thing happened at the start of this year? The best I could think of was that the snow melted**. And this is the graph of that

Which is sort of convincing. But I could do better.

I decided to have a go with Twilight instead; and looking at the graph noticed that it became popular around the time of the recession. I checked, and what I found was that Twilight was a massively more popular search and as a result flattened the recession graph to next to nothing.


So I tried a few variations and finally found the adequately convincing "Edward Cullen" one. Just the right popularity to line up with the recession curve - and, for whatever reason, it fit the general shape quite well.

The point is, if you know how to tweak the variables: the search terms, the time scale, etc. it's not that hard to lie with a fairly convincing graph. Most of the 'Sex and Lesbians' ones in yesterday's post were gamed.

The trick for most searches is - for the year view, you'll get either a peak or a dip around Christmas/New Year; for the week/month, view you'll get peaks or dips around the weekends.

It's just a matter of matching up two or more searches to imply something. And if possible, drawing attention away from the scale (which can be a dead give away).

There are other ways to manipulate results, though - like with the Twilight one. Have a play!

Oh, and in true tabloid headline style, I tweeted the 'proof' as a question. That way, it's not seen as though I'm making some sort of outlandish claim, and the viewer is encouraged to make their own judgement. Albeit a slightly swayed one.


As always, if you come up with anything good yourself, lemme know!


Oatzy.


* I'm obviously not an expert on these matters; I only have a vague idea of what I'm talking about. But there are several books on the subject of statistical manipulation and bullshit worth reading:
How to Lie With Statistics - Darrell Huff
Damn Lies and Statistics - Joel Best
The Black Swan - Nassim Nicholas Taleb
And so on...

** Some would argue that the snow melting was a good thing. And to be honest, I'd be inclined to agree.

Saturday, August 28, 2010

Google Trends

For those who don't know, Google Trends is a site that gives statistics about frequency of certain (Google) search terms, and can be used (tentatively) to compare the popularity of things or look for patterns, etc.

First of all, these results are by no means scientific. But there are still some fun and interesting patterns that crop up. Some of them may be entirely coincidental, or easily explained away, but they're still fun to look at. Also, I may have 'gamed' some of the results :p

So here we go (click to enlarge):


Social Networking


The rise of Facebook, the fall of MySpace and the.. appearance of Twitter. But seriously, look at Facebook go!

For the sake of comparing, here's Twitter vs. MySpace with Facebook removed

And you can see that Twitter overtook MySpace mid-February this year.

And finally for social networking, Facebook over the last 30-days

The spikes correspond with Saturdays, as you'd probably expect.


Other Tech Stuff

So the most obvious things are the fall of XP and the rise of Windows 7 and Ubuntu. Also worth noting are the spikes in Ubuntu's line - corresponding to the April/October release schedule.

And if we look at the month view for last month
you get an idea of the general popularity (of searches for) each OS. Note - Ubuntu more popular than Vista.

And for mobiles

Holy crap, that's a bit spike for the release of iOS4! Most likely connected to the antenna problems associated with iPhone 4. Note also the appearance of android and the relatively consistent popularity of Symbian.

And finally in this section, music

Spikes around Christmas, most likely from people looking to fill their new MP3-players/phones. Also, there's the increased popularity of torrents and the fall in mp3 searches, and iTunes being consistently unpopular. [Kidding, btw]


Sex and Lesbians

You're gonna like these


Apparently people developed a sudden interest in lesbian porn at the start of 2006(?). But it's losing popularity by 2009.

Lesbian porn as a cure for depression? Judge for yourself :p
Is it just me, or are there certain similarities between peaks and troughs of those lines..?
Yeah, I think that one speaks for itself... *cough* Also, PMS seems to be strangely synchronized.


Other Random Patterns

Behold, the power of marketing! (meerkating?)
Did Rihanna's "Umbrella" cause the UK floods?
The Recession - is it going away, or have people just stopped caring?
The Killers - in fact, if you do this for almost any artist/band, you find spikes around the releases of singles/albums etc. As you'd probably expect
Swine Flu hysteria

The Summer of Celebrity Deaths
And since Michael Jackson pretty much trumps everyone else
And what ever happened to Su Doku?
And finally, The Election
(Those yellow spikes are clearly Nick Clegg's fault.)


Summary

So that's your lot. Some interesting stuff in there, and no doubt you want to have a play yourself now.

Some others you might want to look at yourself:
- Diet/exercise [note the spikes and troughs]
- Heating/Air Conditioning [compare UK/Australia]
- Snow, ice cream, etc. [as above]
- Tea/Coffee [compare UK/USA]

A lot of other things, you get the same sorts of shapes with peaks or troughs at Christmas. Have a play. See for yourself.


And if you find anything fun, let me know in the comments or on Twitter.


Oatzy.


[edit] - What do you reckon of this?

Friday, August 27, 2010

The Good Departed Pilgrim Flew Over The Unbreakable Island Road

Shutter Island

You know you've seen a good film when you're left with a lingering feeling of unease once the film's over. It happened after Inception, and it happened after this.

Based on a book by Dennis Lehane, it's the story of a state trooper investigating a missing patient from from an isolated island-based institute for the criminally insane. Or so it would seem.

It's a twist ending movie. And your experience with the twist may vary. I can't say how obvious it is, but I worked it out before seeing the film, but that didn't remove any from it. Though I'm sure the viewing experience would've been quite different if I hadn't. Still, like Fight Club, knowing what's coming doesn't ruin the film at all.

In fact, while I guessed the major twist, that wasn't all there was to it. And the reveal-all flashback scene to what happened in Leo's past is genuinely unsettling.

It's visually appealing, and in terms of the acting, Leo was fantastic. As was Ben Kingsley. If I ever go batshit, I hope I have a psychotherapist like him.

Overall, I reckon it's made it onto my favourites list, so as you'd probably expect, it comes highly recommended from me. Watch it!


The Road


First of all, as far as I can recall, I've never cried at a movie. And I mean actually cried. Sure, I've been close to tears a few times. But The Road... I don't know why, but that ending really got me*.

It's based on a book by Cormac McCarthy, who also wrote No Country for Old Men, another great film. The most basic description I can come up with is that it's the story of a father and son trying to survive in a post-apocalyptic world. But unlike other post-apocalyptic films, the dangers are simply from other survivor, who chose to survive by cannibalism, theft, whatever it takes - not some supernatural horror.

It's a slow burner, unusual in a world of more fast-paced, action-filled films. But when the action does come, it's all the more tense. Unlike a lot of horror film, you're not desensitised to the violence and horror, which makes it all the more distressing. And the film as a whole has a general uncomfortable feel to it. But in a good way.

It seems like one of those films that will likely be on so many lists of films to see before you die.. Not quite a cult classic, but certainly not mainstream, despite its critical acclaim.

Nonetheless, it comes with my recommendation.

[*I'm not claiming to be a really macho manly man who doesn't cry for anyone or anything. I just generally.. don't. Maybe I'm just dead inside :p]


The Departed


I seem to have been seeing a lot of Mr DiCaprio recently. You judge for yourself whether that's a good or bad thing. Also staring Matt Damon and an aging Jack Nicholson, it's a modern mafia film (directed my Martin Scorsese), and a decent one at that.

It's also a little mind fuck-y - you have the cops and the gangsters, each with a rat on the other side and each looking for the other's rat, and it's not entirely clear who is actually on who's side.

Okay, so when I said mind fuck-y, what I meant was confusing. The unfortunate thing is, due to my revising at the time, I didn't entirely pay attention to it. So instead, I'm going to bring up The Simpsons.

As per the memeic refrain - Simpsons did it! In an episode when Skinner introduces a new student into the school - Donny - meant to befriend Bart and rat on all his planned pranks. They even go so far as to include the main musical theme from The Departed and parody (among other scenes) the final cut-scene - an actual rat walking across the background. And in The Simpsons, Ralph popping up to say "The rat symbolises obviousness".

There's also an episode of South Park that seems to parody the end, where the cops are randomly executing each other for some, not entirely clear reason.

Well, I say not entirely clear - it may have been more clear if I'd been paying attention.
It's not what I'd call a must see film. But I wouldn't discourage you from seeing it either. I'll leave it up to your judgement.


Unbreakable

It was sold to me as how a superhero origin story should be done. And it was certainly impressive. M. Night Shyamalan has been getting a lot of abuse lately, but we have to remember, there was a time when he was a respected director. And this is one of his better movies.

As I said above, it is a superhero (and nemesis) origin story. And a very good one at that, not least because it convincingly suggests that heroes could exist in the real world. Possibly. And you have little emotional sub-plots in there as well. But what really wins it is Samuel L. Jackson - the Glass Man - brittle-bone sufferer. The Antithesis of Bruce Willis's hero.

But really, Samuel L. is just consistently awesome in everything. And this is certainly no exception. You should see it - especially if you're a comicbook/superheroes fan; but even if you're not.

And I'm keeping my fingers crossed that there will be a sequel, and that Shyamalan hasn't completely lost his awesome-movie making abilities. Because the ending really does leave the potential for something great to follow.


Good Will Hunting

So this kid, this delinquent working as a janitor at a university - turns out he's a secret genius. Also, he's Matt Damon. Okay, so if it were that simple, the film would be at risk of being trite. But as you probably already know, this film is critically acclaimed. (And possibly won an Oscar?).

I seem to remember that that part was parodied in an episode of Jimmy Neutron. At least, I think it was Jimmy Neutron. Either way. It's always weird seeing a film, having seen various references and parodies before hand. The Godfather is a good example of that (for me, at least).

But no, the actual bulk of the movie is in Will's relationship with his psychologist - played by Robin Williams. I have to say, Williams is actually a really good actor when he's not playing a buffoon [See also: One Hour Photo].

Okay, so this was another film I only half watch (revising for a maths exam at the time), but what I saw of it was impressive. I might even consider buying it. Possibly. It's probably only about £3 in HMV. We'll see how impulsive I'm feeling.

Yeah, I'd recommend it. One of those you might want to see on TV before buying it. But it is worth a look.


One Flew Over The Cuckoo's Nest

Here's another parodied one, in particular in The Simpsons. And having seen it, all of a sudden a handful of jokes make a lot more sense. Like Bart kidnapping the old people and taking them for a boat trip, and 'the Chief' that throwing a water fountain through a window to 'escape' the old people's home. Also, a big chunk of the Michael Jackson episode.

One Flew centres on criminal Jack Nicholson being sent to a mental hospital and on the people he meets and befriends there. And these patients are at the mercy of Nurse Ratchet - an evil bitch of a woman, who, at one point, guilts one of the patients so much he slits his throat. This leads Jack to try and choke her to death - and as a result, gets lobotomised. Then there's the surprisingly touching/disturbing scene where the lobotomised Nicholson is smothered to death by 'the Chief' - as a mercy killing.

It's a damn good film. I suggest you watch it.

Also worth mentioning: the first two episode of series 6 of House (wherein House has been committed) bear some resemblance to One Flew, and in and of itself they're a fantastic pair of episodes. The rest of the series is a bit hit and miss, but you should definitely watch those two.


Scott Pilgrim Vs. The World

I don't know what some of the other reviewers are talking about - misogynistic?! I honestly don't see it. Or maybe I'm just to misogynistic myself to notice? Either way. The point is, it's a good film. And there's a few pretentious, youth/gamer-hating bastards who could use a good slap.

Based on a graphic novel by Brian Lee O'Malley - Scott Pilgrim, at it's most basic level, is a 'boy meets girl' love story. Albeit one that's been smashed together with a video-game to form this stunning, visually pleasing fusion of a film. Of course, this will not be to everyone's taste. But it was to mine, and ultimately, that's all that really matters.

Oh, and also, Scott has to defeat the girl - Romona Flowers -'s seven evil exes, which he does in true video-game style - compete with the defeated becoming a pile of coins.

The film as a whole.. well, I loved it. I've heard other people speak highly of it. But it's kind of a niche film. Odds are, the people who'll like it the most are those around student-aged. Which is not necessarily a bad thing.

It's funny, it's romantic (but not sickeningly so) it's just generally good fun, and it has 'Vegan Police'. Oh, and did I mention it's visually stunning?

Yeah. If you're around student age or are just a big nerd (or both), I'd recommend it. If you're not, maybe read up on it first..?

[Only downside - not nearly enough prancing :p]


Oatzy.

Thursday, August 26, 2010

The Train Problem

It started with a simple question - will I get a seat on the train?

While it may seem like a straight-forward question, since I thought of it, finding a solution has been the smoldering bane of my existence. I tried several approaches in the past, each with varying degrees of success. But the one I'm going to outline is the best I've managed - it makes no assumptions and is based on simple logic. But more on that shortly.

Approach

Whether you'll get a seat depends on two things:

1) the total number of seats on the train
2) the number of passengers on the train

For (1), the number of seats is countable (prior to boarding the train). So what you need to try and calculate/estimate is (2) how many people are on the train, and therefore, how many seats (if any) will be available.


Modelling

The number of people on a train when it leaves a station can be described as follows
Passengers = (passengers on-board when the train arrived) - (passengers who get off) + (passengers who get on)

Or as a difference equation; at station i:
where N_i is passengers on-board, D_i is passengers 'disembarking' and B_i is passengers boarding.

But that's only useful if we know N_{i-1}, D_i and B_i - and to be fair, we can count the people on the platform for an estimate of B_i. But, how do we know, or work-out, the other two variables?

Consider a simplified version* - a train that visits 4 stations (total):

So what the diagram shows is, we can think of the problem in terms of passengers traveling between any two given stations. Define a function T(i, j) as the number of passengers traveling from station i to station j (we'll look at T in more detail later).

So for the example above,

N_0 = passengers getting on at 0; passengers traveling from 0 to 1, 2 and 3 = T(0, 1) + T(0, 2) + T(0, 3)
N_1 = passengers already on minus getting off plus getting on = T(0, 2) + T(0, 3) + T(1, 2) + T(1, 3)
N_2 = T(0, 3) + T(1,3) + T(2, 3)
N_3 = 0  [since everyone gets off at 3]



And from all that, we get that B_i and D_i can be written mathematically as
And all of this can be combined into one 'train equation'

Usage

So once you've solved that equation, your probability is simply

(Where S in total number of seats available.)

And that's all well and good, and theoretically it works. But it's also useless if we can't define T(i, j).

So how do you define T(i, j)?

First of all, logic says that it should be dependent on the popularity of the stations in question. For example, you'd expect more people to be going Sheffield to Birmingham New Street than Derby to Birmingham International.
[if you don't know what I'm on about, you'll just have to trust me.]

And for this, we can work from something like this [a spreadsheet giving details on the use of every station in the UK]. The only downside is, I haven't figured out the best way to use this data yet.

The other major thing to consider is temporal effects - you would expect, for example, higher use at rush-hours etc. Similarly, over the course of the year, you might expect higher usage, say, around Christmas. And if you've been on a train around Christmas, or at rush-hour, you'll be familiar with this horror.

So the T-function might involve something to distort it into this sort of shape

But with, maybe, a less dramatic dip in the middle. That equation, in case you're interested is a variation on Sin(x)[2Sin(x) +1]

Pro tip: I have found that the best time to travel in the afternoon is around 3 o'clock.

But realistically, these are the sort of things you'd have to measure 'experimentally'. And being a theoretical man, that's really not for me to bother with.


Practical Advice

Of course, all this assumes that you don't have a seat reserved. If you do, all this is null and void. But otherwise..

The major caveat to this is that, due to the complexity of the system, this approach can't tell you exactly how many seats there will be. At best, it's a general estimate.

In fact, in general, this approach is really impractical, and as a result nigh on useless. Instead, you're best bet is to take steps to actively improve your odds. Most of this is fairly obvious, but still..

So for example:

1) Stand at the far end of the platform (away from the crowds) to reduce your per carriage competition.
2) If you know which way the train is coming in, try to stand towards the back (for Virgin Trains). Carriage C/D is usually the completely unreserved one.
3) In the subtlest and calmest way possible, get to the front of any queue at your door of choice.
Pro tip: Stand side on to the train so you're facing into the carriage. There's a good reason for why that gets you on quicker, but I can't, for the life of me, remember where I read it. But I do know from experience that it works.
4) Once you're on, quickly assess how many free seats there are. If they seem limited, grab the first (unreserved) one you see. If there aren't any unreserved, just grab the first free seat you come to and pray no-one tries to claim it.
5) If all else fails, just remember - the cool kids sit on the floor (Y)



Conclusion

Another thing to note is that this could ultimately be applied to an form of public transport. But there's a certain added complexity in buses (and some trams) since they won't necessarily visit all stops on a route. But this can be approximated by making the T-function for these stops zero.

As will all my maths-y posts so far, this is really more of an intellectual exercise, that can't really be applied practically. But there you go.

'Til next time,


Oatzy



[*funny story, the inspiration for this approach actually came from Quantum Physics (quantised energy levels, etc).  Yeah, I know. I'm a nerd.]

Saturday, August 14, 2010

A Handful of Film Reviews

Thanks to LoveFilm, my recently seen movie quota is significantly up at the moment. And you lucky people get to enjoy my so called reviews.

Beginning with..!


Frequently Asked Questions About Time Travel




What Shaun of the Dead is to zombies, FAQ about Time Travel is to, well, time travel. And the comparison is obvious and no doubt one that's been used numerous times before (including in the trailer). But, it does capture the general style and feel of the film quite well. It's that quirky, off-beat, British humor we've all grown to know and love (unless you haven't).

Staring Roy out of the IT Crowd, Shakespeare out of that episode of Doctor Who and this other guy, the misadventures of these unlikely heroes centre around the men's bathroom of their local pub where there's some sort of time leak - Weirdness ensues!

And to be honest, I thought it was fantastic. I mean, it's the sort of convoluted time travel madness that Steven Moffat would be proud of, and frankly I welcome it with open arms. And like all infuriating time travel stories, it ends with the major events of the film not actually having happened. Technically.

If you like Doctor Who, if you like time travel, if you like British comedy.., you should like this film.

I'd definitely recommend it.


Catch Me If You can

Great fun. The life of Frank Abagnale Jr. - renowned fraudster. The man who could charm the pants off of anyone. Then slip out the window with all your money. But you'd be too damn impressed to care.

I wouldn't buy it on DVD (unless I were feeling particularly impulsive). But odds are, if you wait til Christmas it'll be on then, if not before. And it is worth watching.


The Imaginarium of Dr Parnassus



Heath Ledger's last film. Which is a shame, because he was damn good in it! Johnny Depp was similarly on form; Jude Law and Collin Farrell, nothing special. And Lily Cole was surprisingly not crap!

The story itself surrounds Dr Parnassus and his on-going deals with The Devil - the latest of which is first to five souls, the prize being Parnassus' daughter. And thank God Heath Ledger showed up (hanging from a bridge) or Parnassus would have failed miserably. I mean he did still failed, but it's a lot more intricate than that.

It's quaint and magical and charming; But surprisingly underwhelming. I mean it was 4 out of 5 stars good, but I was expecting something a little more.. epic. If you were planning on buying it, I'd give it a couple of months til the price drops again, but it is worth watching nonetheless.


The Mist

For the love of God, why didn't they kill that nut-case sooner?! The Mist, for those who don't know, features the most infuriating religious psychopath you will ever see, and it'll have you wanting to round up all the God-fearing and have them shot. You know, just in case.

Based on a book by Stephen King, it's fantastic, end of the world, horror that's more about how people can turn against each other in dire situations, than about the actual threat. Though the monsters are suitably formidable.

The Dream Lord himself (Toby Jones)co-stars as friendly shop assistant and surprise bad-ass, and he was just plain amazing. So how dare they let him get eaten when he was so close to freedom and safety.

The other amazing thing about The Mist is its ending. So bittersweet, you'll hate Stephen King for daring to think up something so sinister. But I'm not going to give it away.

Just watch the God damn film! About £10 in HMV, but if you can find it in ASDA (Living) it's £3, and for that price you might as well. Online, you'll have to look it up yourself.


A Scanner Darkly

The rotoscoped marvel - it's basically a cartoon traced from live action film. And it works to good effect. Especially in the more bizarre scenes.

Based on the book of the same title, this is a semi-autobiography of a period of Philip K Dick's life, and as such, it's one of those stories that doesn't really seem to be going anywhere until the big reveal at the end. And what you have at the end is that reveal that a drug rehab clinic uses its most messed up patients to (secretly) grow the drugs that put them in rehab. Keanu was purposefully made addicted to the drugs (unbeknownst to be) by the government so he could get them their evidence.

Robert Downey Jr is great in it. Keanu Reeves is Keanu Reeves. Overall, it's decent. I wouldn't pay for it. I probably wouldn't be bothered about watching it again. But it was worth watching the once. So if it's ever on TV..



Total Recall

"I just had a terrible thought - what if this is a dream?"

Inception, eat your heart out! Based on the story "We Can Remember It For You Whole-sale" by professional mind-fucker, Philip K. Dick.

Staring Governor Schwarzenegger, for the most part it's Sci-fi action thriller, and a decent one at that, if a little flamboyant.

But it gets bonus points in my book thanks to how it's framed. It starts with Arnie going to 'Rekall', a company which offers 'holidays' in the form of implanted memories (claiming that it's just as good as actually going on the holiday). But they offer Arnie something special - an adventure holiday, where he plays the part of a secret agent, who has to save Mars.

But when the machine's started up, it triggers some erased memories that, in fact, he was already a secret agent. Then shit gets real as he's hunted down by his ex-employer, eventually venturing to Mars and so on.

Or does he? Okay, my description was biased because I reckon it was all just implanted memories, but if you watch it yourself you may disagree. And it is just a massive mind-fuck.

The ending may not be as subtle as Inception's. But it doesn't really need to be. It suffices. Again, it's not something I'd pay for, but if you can see it for free, you definitely should.

Apparently they're remaking it as well, so should be interesting to see what they do with it.


And finally


Mr Nobody



My new favourite film. Why, oh why aren't you available outside of France yet? Over a year ago I saw a trailer for it on the Empire website and I've been waiting ever since. Anyway, I did finally get to watch it. And wow!

It stars Jared Leto (the 'pretty boy' from Fight Club and lead singer of 30 Seconds to Mars), as the dubiously named "Nemo Nobody"* - but I'm willing to forgive that, because it's just so damn good. It's Sci-fi with a heavy dose of quantum physics and it's three love stories for the price of one. In fact, Jared essentially plays 12 different possible outcomes of the same life - any and all of which could be real. And the big reveal is just magnificent.

The cinematography is just plain gorgeous; the music is perfect, visually it's stunning, and the DVD need to be released over here right now!

As I may have mentioned, you can't buy it outside of France yet. But when you can, you should. And if you can't wait til then, well, there are other places you can find it...

[*- nemo is Latin for nobody]


Oatzy.

Patterns in the Lottery

Back in 2009, Derren Brown once again shocked the world with his witch-craft, as he predicted the lottery, live on TV.

Later that week he explained how he did it - wisdom of the crowds. Which is complete and utter bullshit. But it was a magic trick, so what do you expect? If anything, the whole incident was probably an ingenious marketing ploy for "The Events" series of which it was a part. But I digress.

The idea of Wisdom of the Crowd is that if you get a group of people to make a guess at a quantity (say, the number of coffee beans in a jar), then take the average, the average will be surprisingly accurate. It's just an application of the law of large numbers.

But this doesn't work in the case of the lottery, because the lottery is completely random, and taking the average of all the previous numbers would give approximately the same six numbers for every week. Which doesn't happen.

But are there any patterns in lottery numbers?

The answer is, in fact, yes!


NB/ The explanation on this one is going to be sparse because I did all this a while back and didn't have the sense to keep clear notes on what exactly I was doing.


Statistical Analysis

Thanks to the internet, I managed to get hold of all the winning numbers (for the standard UK lottery), which at the time, totaled 1432 sets of numbers.

Plotting the occurrences of each number, you get something like this:

So you've got some obvious peaks and troughs there - the biggest peak being 38. So you'd think your best chance would be picking the six highest peaks, or lowest troughs if you subscribe to the "they're due to come up" theory.

But, obviously, by the law of large numbers, that line should eventually flatten out.

[Incidentally, the one time I did play the lottery after doing all this, I pick 38 as one of the numbers and it came up. Just saying.]

I then put the numbers in numerical order and got the following sets:

Mean - 7, 15, 22, 29, 36, 43
Mode - 1, 9, 23, 31, 38, 49
Median - 6, 14, 22, 29, 37, 45

And if you can draw anything from at, it's that the 'average' set of numbers tend to be relatively evenly spaced. I did some measures of spread, standard deviation, etc., and the results seemed to agree. But that wasn't that interesting.

But what is slightly interesting is what you get when you plot the numbers against what position they appear in, in the ordered sequence:

[The second one is odds of number, x, being in the i-th position in the ordered sequence.]

So the pattern there isn't obvious, but the is a definite pattern.

Based on the first plot, I tried fitting the numbers to Gaussian curves, and got something like this:

Which all together looks like this

Which is a decent fit. But the truth was, there was a much simpler, more fundamental approach to fitting the curves.


Combinatorics

The way you work out your odds of winning the lottery is relatively straight-forward - explained here. Have a quick read of that. Can't be bothered to explain myself.

Now, again, I can't remember how I derived this, but the probability of the i-th ball being x (when the balls are put in numerical order) is given by:

And using that, we see what the plots above should actually look like:

Which is the exact same shape, only smoother (as you'd expect).


Problem

So say you want to know the probability of a certain (ordered) sequence, you just take the product,

But that's where a problem arises.

The first (smallest) number is most likely to be 1, the last (largest) is most likely to be 49, etc.

Which does make sense. Say the smallest number is 1, then the other five numbers can be anything (except 1). If, on the other hand, the smallest number is 44, then the other numbers can only be {45, 46, 47, 48, 49}. So obviously, a sequence starting with 1 is massively more likely than a sequence starting with 44.

But that then seems to imply that there is a most likely sequence {1, 11, 20, 30, 39, 49}. And running the numbers, you find that that sequence is much more likely than {1, 2, 3, 4, 5, 6}.

It's been a favourite of the mathematicians that all sequences of lottery numbers are equally likely (supported by calculation) - that {1, 2, 3, 4, 5, 6} is just as likely as, say,  {4, 12, 23, 33, 39, 48}.

So here's my challenge to you - spot the hole in my ordered probability calculation.

Or is there a hole? What is actually going on here?


Oatzy.