Tuesday, November 4, 2014

The reality of Melbourne Cup betting

An interesting proposition just came up on my twitter feed. Tom Waterhouse, the smug git you see on TV spruiking his bookmaking service, is offering $25 million dollars to anyone who can pick the first 10 runners in the Melbourne Cup in order - and it only costs you $10 per try! (apparently you get 10 tries at most, don't get greedy now!)

Sounds good, right?

Well, no. Intuitively most people can smell a rat straight away - after all, it's difficult to win the lottery and that's only 6 numbers that need picking (though there are more of them). But it's far worse than that. Even with two horses scratched, if we naively assume each horse has the same chance of winning, then picking the first horse is a 1 in 22 chance. Picking the next horse is then a 1 in 21 chance (as we can eliminate the winner), then so on until the 10th horse is a 1 in 13 chance. All up, the probability of doing this is about 1 in 2 million million. Even if the entire population of Australia at about 23.6 million (including children!) put in their 10 bets each, there would be an 0.01% chance that anyone would win.

The smart gamblers are probably now thinking "well, each horse doesn't have an equal chance of winning - I can exploit that!". And they'd be right! So let's look at the odds of each horse winning (I've used the fixed odds at Betfair but feel free to substitute your own). We can estimate the probability of each horse winning from the bookmaker's odds, and this is as accurate a representation as we're likely to find without significant effort - after all, it's in the bookmaker's interests to know the probabilities as accurately as they can to make the most amount of money! A formula to estimate the probability of a particular horse winning is:

1/<the odds for your horse> divided by the sum of (1/odds) for every horse.

Doing this gives us a probability of about 16% of the favourite, Admire Rakti, winning. So let's put our money on the favourite winning, followed by the second favourite in second place, and so on. Once our favourite goes past the line, we then need the second favourite (either Fawkner or Lucia Valentina) to come next. We can estimate the probability of this happening by dividing its probability of winning (about 13%) by the probability of all the remaining horses' probabilities of winning combined (about 84%), giving us a probability of about 15% of this horse coming second given our favourite has already come first.

Again, we rinse and repeat until we get through the first ten horses. This gives us a much nicer final probability of 1 in 28 million. Again, naively you might think that if everyone in Australia had a go at this, surely with 236 million bets, we'd be able to do it pretty easily.

Unfortunately though, if everyone in Australia put their bets in here, they're not all going to be able to pick this most likely scenario. If they did then either everyone would win, sharing the $25 million dollars and getting $1 each from their outlay of $100, or nobody would win! Instead, everyone would have to organise to pick the 23.6 million best odds. And then, even if someone managed to win, Tom Waterhouse would still be pocketing $2,360 million dollars and only having to shell out $25 million, making his smug face even more unbearable...

Friday, July 25, 2014

Fruits of procrastination

Winter tends to be a bit slow for me, in terms of work and productivity at least. It gets that little bit harder to concentrate, or stay motivated on tasks that are... the less fun parts of my job as a research scientist.

To that end, I thought I'd keep this blog alive by sharing some of my afternoon's procrastination, which I thought was kind of cool and a real reflection of how even now in 2014 we're still a fair way away from 'science fiction' in a lot of our endeavours. Artificial intelligence is a big one of these - we've achieved a lot since electronic computers hit the scene not-so-long ago - but our imaginations at least for now far outstrip what we've been able to do. Exactly because it excites people's imaginations, progress is heavily trumpeted - and make no mistake, some cool things have been done, especially in AI-friendly environments such as strategy games (chess is probably the most obvious example here).

Unfortunately, things get much more difficult for AIs when we go from simple games where the options are finite and often manageable to more realistic real-world tasks where there are numerous things that need to be coordinated at once - something that our human brains are evolved to deal with but computers have no such base to work from. The programmer can of course give the computer insights as to how humans would deal with things, and sheer processing speed can help make up some of the difference - any first-person computer gamer can attest to AIs being potentially very skilful (though often easily fooled by unusual strategies).

My afternoon's procrastination has involved looking at RoboCup - a series of competitions based around the game of soccer (or football, depending where you're from). The AIs actually look reasonably clever in the simulated 2D version. Keep in mind that to keep some degree of 'realism' each AI player has been given some simulated 'noise' to their sensors so they don't have perfect information, much like players in real life.


Once you get to 3D though, things start looking seriously clunky. Each virtual robot has 22 different joints to control - and it shows. They're very good at doing set combinations of movements (like a set shot at goal, given enough time) but it's not exactly what you'd call graceful...


When you convert this to real life robots, things get even worse. Really the only thing these robots can do consistently well is get up after they've fallen over - and after watching this video for any length of time you'll understand why this is a vital necessity:


The stated goal of RoboCup is that "by the middle of the 21st century, a team of fully autonomous humanoid robot soccer players shall win a soccer game, complying with the official rules of FIFA, against the winner of the most recent World Cup". At the moment that looks kind of optimistic, but when you consider how far computing came from the earliest personal computers in the 80s to the present, then extrapolate to 30 years in the future, their goal doesn't seem quite so unrealistic.

Monday, April 21, 2014

DIY animal surveys (part 2)

So after the success of my first forays into using motion detection to film the neighbourhood cats, I thought maybe I'd get a little bolder and set up the equipment next to the house. I originally decided against this because I thought any cats (especially kittens) would be scared off by the proximity to light and humans, but considering how bold the last one was, it'd be worth a try!

The next morning, a quick perusal of the food bowl suggested that nothing had been eaten, so I wasn't feeling particularly optimistic as I went to review the footage - yet again, I needn't have worried. This time I picked up not one, but two feline feeders, obviously working together:




After their first joint perusal of the offerings on display, they individually came back to the bowl...


... and laptop...


... again...


... and again - often looking around curiously at objects (or potentially off-screen cats) as they did so.


The black cat was evidently the wilier of the two - while the above photos were all taken in the space of five minutes, it returned a couple of hours later apparently having ditched its companion to see if any tastier food had magically appeared in the bowl that it could have for itself.


Tuesday, April 15, 2014

DIY animal surveys

Our neighbourhood is a cat neighbourhood. Walking along the streets at dusk or after dark, you can see at least a small handful of local cats prowling around or sitting smugly on their owners' driveways soaking up the last bit of heat of the day. So it didn't come as any surprise to me that every time I discarded the scraps outside that our own (indoor) cat for whatever reason didn't eat, they'd invariably be gone the following day.

I thought it worth investigating exactly which cat was taking these scraps. We've occasionally seen kittens wandering around our yard and more regularly around the neighbourhood, and I was a bit concerned for their welfare - so I thought it would be good to know if they were feeding in our yard and whether they could be collected for a rescue shelter.

So I got out my old crappy laptop with its old crappy webcam and set it up outside in our garage, somewhere that rain/wind wouldn't bother it (though it's old enough that I wouldn't have been too distraught if something did happen to it), and turned on a motion capture software program (I can thoroughly recommend yawcam - it's free!). I was unsure whether our nightly visitor would be put off by the outside light I left on for the webcam to be able to see, and my fiancee was understandably cynical as to whether the process would work at all. So come next morning, I rushed out to reclaim my laptop, and after flicking through the images captured during the night, felt vindicated at seeing this photo come up at 12.11am:


I needn't have worried, though, as I'd forgotten two basic attributes of cats. Firstly, they are curious and attracted to new and interesting objects - and secondly, they're attracted to warm objects. The laptop that had been running all night out in the cold was both of these things! Thus, at 2.23am, the vision went entirely black, followed by images of the cat walking directly in front of the laptop sniffing at it:


Then an hour later at 3.14am it returned for another look at the laptop before scurrying off, not to be seen again in the footage (though it may well have returned - the laptop stopped recording when Windows decided to restart after downloading a security update... a lesson for anyone wanting to try this at home!)


It just goes to show that with the modern (and sometimes slightly less modern) technology we have available and take for granted, it's actually pretty easy to set up some fun and interesting projects to see what's just outside your door. It's probably worth noting, though, that the webcam didn't actually pick up any evidence of said cat eating the food left out for it, even though it was definitely gone the next morning!

Tuesday, January 7, 2014

Testing the Bechdel Test

So, recently this article came out showing that of the top 50 movies of 2013, those that passed the Bechdel Test made more money overall at the US Box Office than those that didn't. For those not in the know, the Bechdel Test evaluates whether a movie has two or more named women in it who have a conversation about something other than a man. The test seems simple enough to pass, but surprisingly quite a lot of movies don't! Of the 47 top movies that were tested, only 24 passed the test (and at least* seven of those were a bit dubious). Gravity was understandably excluded from the test because it didn't really have more than two named characters**, and apparently no-one has bothered to test the remaining two.

The article comes with this nifty little infographic:



I've seen a couple of complaints on the web by people saying that this isn't enough proof - the somewhat ingenuous reasoning I saw was that the infographic shows totals and not averages, so can't prove that the average Bechdel-passing film performs better. Though there are more passes (24) than fails (23), the difference is not nearly enough to account for the almost 60% difference in total gross sales. The averages can quickly be calculated from the infographic above - the average passing film makes $176m, and the average failing film makes $116m, still a very substantial $60m difference!

A more reasonable criticism is that it may be possible that things just happened this way by chance. Maybe this year a handful of big films happened to be on the passing side, and if they had failed there'd be no appreciable difference? Well, we can test that as well using the information in the infographic. All we need to do is run what's called a randomisation test - this is where we randomly allocate the 50 tested movies in this list to the "pass", "fail" and "excluded" categories in the same numbers as in the real case (so, 24 passes, 23 fails, 3 excluded). We can use a random number generator to do this, or if you're playing along at home, put pieces of paper in a hat, whatever. We repeat this process a large number of times (I did it 10 million times) and see how often we can replicate that $60m difference between passing and failing films or better by chance alone.


It turns out that when you put your pieces of paper in a hat to make your own test, you'll only be able to beat the actual difference 0.71% of the time, or about 1 in 140 times. This is pretty good evidence that it's not a fluke and that the Bechdel Test really did influence movies' bottom lines this past year. One thing that we can't say based on this is whether this is a direct effect - i.e. that people consciously or subconsciously decided to go watch passing films over failing films. It could be that there is some indirect, or confounding effect, causing this phenomenon. For example, maybe directors who write films that pass the test tend to be better filmmakers in other ways which make people want to watch their films more? Either way, a trend towards more women in substantial roles in films can be no bad thing! (though it's worth mentioning that passing the Bechdel test by no means guarantees a "substantial role", and even failing movies can have their strong points - see this link)


* Having watched Man of Steel, I'd argue that it was pretty dubious too - I think the only non-about-a-man conversations between two women were one-sided one liners (hardly a conversation)... in any case, any feminist points it may have gained were swiftly taken away in my book by the female US Air Force Captain being mostly portrayed like a ditz rather than as a dedicated leader of people required for the rank. More here.
** So I'm told. I haven't watched it yet.