Posts Tagged ‘maths’
Geek poetry
I’ve not posted for a while: I’ve been busy doing things other than procrastinating! OK that’s a lie, but the procrastination hasn’t taken the form of blog posts for a while. My website looks much the same as ever, but lots has changed under the hood, as it were. It now validates as XHTML and the columns are the same height and extend to accommodate as much text as needed. Hoorah. I also have an essay I’m rather proud of. (Actual work, shock horror!) It is probably over long and not all that much of it can be adapted to fit into my literature review, but I’m still happy with the (almost) finished product. On an unrelated note, here are some poems that appealed to the geek in me.
Here is the halting problem proven in poem form.
A poem composed entirely of punctuation. (I may have linked to this before.)
I remember a maths lecturer at Warwick starting a lesson by telling us:
Integral t-squared dt
from 1 to the cube root of 3
times the cosine
of three pi over 9
equals log of the cube root of ‘e’.
More maths limericks here.
A history of Western philosophy in limerick form you say? Well why not?
And of course there’s limerickdb. The marked geeky charm of the top 150 indicates that this project is from the chap behind xkcd.
And while it’s not a poem, it’s certainly the same ballpark.
And finally my own contribution thanks to getting bored during measure theory lectures. I give you a haiku about basic measure spaces:
A finite union
of disjoint rectangles is
elementary
I have tons more of these on some scrap of paper in my old notes folder. I also wrote a limerick about Rene Magritte once… (I rhymed “Rene Magritte” with “ceci n’est pas une pipe”)
Enumerating structure on sets, again.
The number of partitions on an N-membered set is called its “Bell number“. The number of strict total orders, I’m not sure about that… There is some relevant information here.
Well it’s good to see those problems solved, and I’m glad they weren’t trivial… Here is a more general issue. How many relations are there on a set? How many transitive? And so on.
So, a relation is simply a set of ordered pairs. So there are 2^X possible relations if there are X ordered pairs. For a set with N elements, there are N^2 ordered pairs. Thus 2^(N^2) relations on N elements. To give you an idea of scale, there are 65,536 relations on the 4 element set. But there are only 15 partitions on the 4 element set (not 18 as I said before; I counted each 2+2 partition twice.) So the properties of being transitive, reflexive and symmetrical must seriously cut down the number of relations! The only thing I’ve concluded in answer to this question is that there is an upper bound on the number of possible total relations on N elements: 2^(N^2) – 2^([n^2]/2). This is because the property of being total means that the size of the set of ordered pairs has to be big enough to contain at least one of (a,b) or (b,a) for every a,b. So small sets of pairs are ruled out.
Python and primes
Today I spent a while reaqcuainting myself with Python and IDLE and trying the first few project Euler challenges. I decided it would be worthwhile to have a list of the first few prime numbers, that would make my job easier for several of the problems. (I don’t care if that’s cheating, I still had to make the list of primes…) So I wrote a program to find primes. It’s tremendously inelegant and probably terrible inefficient, but I’m only going for the primes under 10,000 or so. It doesn’t take long to get them. Then I decided to write something that would find the prime factors of an input. The idea is that if the number to factorise is bigger than the biggest prime in the list, it will run the “find primes” program, until it has big enough primes. Anyway, I haven’t got there yet because it’s late and my brain won’t work properly any more. But I do have a number that will give you prime factors, as long as you give it small enough inputs. To try it out, I ask it for the prime factors of the first number to come into my head: 24. [2,3]. Awesome. Now, try it on something bigger. 2400? [2,3,5] hm. Try something else 24001. Too big. 2401 [7] Whaat? What are the odds of my pick 7^4 to test a prime factorisation program. Anyway, eventually I found a number random enough to satisfy me that the thing was working…
The thing is, the whole thing kind of pulls iteslf up by its bootstraps. So if, somehow, a number that isn’t prime crept into the list or a prime was missed out, the whole thing would be invalid. Because it only checks for divisibility of numbers in the list of primes… I should write some sort of consistency check program to make sure all the numbers in the list are not divisible by any of the smaller numbers in the list.
Why people are irrational and stupid. Part 1
So this is the first in what I hope will be a regular feature on this blog highlighting some paradoxes and thought experiments that show that people are not very good at thinking rationally. I hope to convince you that people really do suck at probabilistic reasoning and sometimes even simple logical reasoning fails. This is motivated partly by misanthropy- I think people are stupid. And partly by my fascination with these kinds of puzzles. A third motivation is that I think epistemology based on rational degrees of belief (Subjective Bayesianism for example) is flawed. Particularly in cases like quantum mechanics. But more of that in a later post. For now I’ll stick to the Monty Hall problem.
Monty offers you three doors- A,B and C. Behind one door is a car and behind the other two doors are goats. The idea is to pick the door with the car behind it because then you win the car. But if you don’t want a car, or you do want a goat, imagine that behind one door is something you really do want and behind the other two doors are things you don’t want. Like one door could be a treasure chest full of gold doubloons and behind the other two doors are scurvy. Or behind one door is cake and behind the other two doors is death. Or behind one door is Hans Christian Andersen’s The little mermaid and behind the other two doors is Katie Price’s Mermaids and Pirates. Behind one door is Battleship Potemkin and the other two doors the Pokemon movie. You get the idea.
So you pick a door. WLOG assume you picked door A. Monty now opens one of the other two doors and reveals a goat (scurvy, whatever). Now, you are offered the chance to swap doors. Should you swap doors? The answer is that yes you should. The probability of your winning a car by swapping doors is higher than if you stick with your original door. That does seem a little counter-intuitive, does it not? Surely once one of the goat doors has been revealed, there are two doors remaining and one has a car behind it. 50-50? If you are thinking that, then you are irrational and stupid. That’s not how to think about it.
Think about it this way- 2/3 of the time, the first door you pick, door A, will have a goat behind it. In those circumstances, one of door B or C will have the car (doubloons etc) behind it. So Monty won’t be able to open that door, he’ll have to open the other one. Which means switching will give you the car door. That happens 2/3 of the time… So you should always switch.
To make this even clearer, imagine there are 100 doors. 99% of the time you pick a goat door. Now Monty opens 98 goat doors. To leave you with your door and one other door remaining. So switching doors will net you a car 99% of the time.
There are two strategies. Either always switch or never switch. (OK, there are strategies where you randomly switch with probability p, but trust me setting p = 1 is optimal…) So two options. If you decide to never switch, you get the car 1/3 of the time – those times you pick the right door first time. Always switching, you’d think, would get you the car at least 50% of the time. In fact it’s even better than that. It gets you the car 2/3 of the time. Because if the only strategies are switch or don’t switch, and the only outcomes are win or don’t win; if one strategy wins 1/3 of the time, the other strategy has to win the other two thirds of the time.
Why isn’t it 50%? Because having Monty open a door tells you more about the door you haven’t picked than it does about the door you have picked. If you still aren’t convinced and think it is still 1/2, I suggest we meet up and simulate the game with playing cards, or play the card version of Bertrand’s box paradox. For money. I promise you, if we play for long enough, I will be able to buy myself a car with the money I swindle out of you. Except that I can’t drive. So I’d be looking to buy a chest full of gold. YARRR.