I use this blog as a soap box to preach (ahem... to talk :-) about subjects that interest me.

## Tuesday, November 20, 2012

### Misunderstood Science #2 - Another question of probability

In this article, I want to describe a problem that illustrates how to correctly estimate probability in a way that will surprise the non-statistician.

Here is the problem: An American friend of yours has two children. You know that one of them is a girl, but cannot remember the gender of the other child. What is the probability that they are both girls?

Many people would equate the lack of information concerning the gender of the other child with equal probability of the two possible genders, and answer 50%.

Their reasoning would be completely wrong but, as it turns out, their answer would be correct, at least in practical terms. If you read and understood my previous article on probabilities http://giuliozambon.blogspot.com.au/2012/11/misunderstood-science-question-of.html, you might know why. But let’s proceed in order.

For the genders of two children, there are four possibilities: MM, MF, FM, and FF, which represent the sample space of the problem. If we assume that boys and girls are equally probable, the four possibilities are also equally probable, at 25% of probability each. As you know that one of the children is a girl, you can exclude the MM case. As a result, you are left with three possibilities and can conclude that the probability of both children being girls is 1/3, or approximately 33.3%. And obviously, the probability that your friend’s other child is a boy is 66.7%.

But then, why did I say that the 50-50 answer is correct from a practical point of view? There are two reasons:
1. No parent gives the same name to their two daughters.
2. The frequencies (and hence, the inferred probabilities) of given names are very low.

Let’s start by taking into consideration that two daughters in the same family always have different names. We do so by splitting the ‘F’ of the above possibilities into ‘x’ and ‘f’, where ‘x’ indicates the girls with a particular first name, and ‘f’ the other girls, who have any other name. This results in a sample space consisting of MM, Mf, Mx, fM, ff, fx, xM, xf, and xx.

‘x’ can be any name we want, including the name of the daughter we know to belong to your friend’s family (even if we don’t know that name). Then, after discarding MM as we did before, we can also discard the possibilities that don’t contain ‘x’. This leaves us with Mx, fx, xM, xf, and xx. Now, as parents never give to two daughters the same name, we can also discard xx, and remain with the four possibilities Mx, xM, fx, and xf.

If we assume that boys and girls are on average equally probable and that the genders of children of the same family are independent from each other, we can calculate the probabilities associated with the four possibilities:
PMx = PxM = PM * Px
Pfx = Pxf = Pf * Px

We can use the frequency ‘y’ with which the name ‘x’ occurs among girls as an estimate of its probability, and rewrite the two expressions as follows:
PMx = PxM = PM * PF * y = 0.25 * y
Pfx = Pxf = PF * (1 – y) * PF * y = 0.25 * (y – y2)

As you can see, if y2 is much less than y (i.e., much less tan 1 as stated in our condition 2), all four possibilities have, for all practical purposes, the same probabilities. Then, the probability that the children are both girls is indeed 50%.

But is it true that all names have a frequency much less than 1? If you look at the web site of the US Social Security Administration, you will find the page http://www.ssa.gov/oact/babynames/limits.html from which you can download the number of children born in any particular year and given any particular name (but only if that name was given to at least five children).

Let’s say that your friend’s daughter was born in 2011. Then, you quickly find out that of the 33,723 names listed, out of a total of 3,623,043 girls, the most frequent girl name was Sophia, which was given 21,695 times. If your friend gave to his daughter the name Sophia, with y = 21,695 / 3,623,043 = 0.060, the resulting probability for two girls is around 48.45%.

Perhaps 48.45% is not close enough to 50%, but consider that the average occurrence of any name is 33,723 / 3,623,043 = ~108, which provides y = 0.00003. Then, the probability of two girls not knowing the name of the daughter your friend certainly had becomes 49.999%. Or perhaps you find out that the name of your friend’s daughter is Hilde, which in 2011 only occurred 5 times out of 3,623,043. In that case, the probability of him having two daughter is almost exactly 50%.

All in all, we can conclude that 50% is, for all practical purposes, correct, even if the reasoning of many people to reach that value is wrong.

## Friday, November 16, 2012

### Yet another book of puzzles

The last thing I would like is to put off readers of this blog by posting too many advertisements for my books. But, after all, I don’t publish things too often, do I?

I have just released a new puzzle book:

For the time being, you can only buy it from Lulu in print for AU\$ 9.99 or from Smashwords in various e-book formats for US\$ 1.99. It will take a while before you will find it on Amazon, Barnes & Noble, etc. It always does.

This book contains 100 difficult CalcuDoku puzzles. CalcuDokus, introduced in 004 as KenKen® (a registered trademark of Nextoy LLC), is a 9x9 numeric puzzle similar to Sudoku. But, unlike Sudoku, CalcuDoku doesn’t require you to learn complex strategies.

Each cage contains a target number and a code to indicate one of the four basic operations: “x”, “+”, “-”, and “:”. To solve a CalcuDoku puzzle, you have to solve all its cages; and to solve each cage you must write in its cells the digits that give you the cage target when you apply to them the cage operation.

Unless a cage consists of a single cell (in which case there is no operation and its solution coincides with its target), you can solve it in several ways. For example, a 2-cell cage marked “7+” admits six solutions: 61, 16, 52, 25, 43, and 34. But only one of those solutions is correct and will let you solve the whole puzzle.

You can discard the wrong solutions of all cages by repeatedly applying the rule that each digit between 1 and 9 can only appear once in each row and column.

The first sixty puzzles of this book consist of randomly generated cages, like the following one:

They are difficult, but I limited their difficulty by setting to 2 the maximum number of cages admitting more than 200 combinations. Therefore, although I haven’t tried them all, I’m pretty confident that they can be solved analytically. That is, without having to guess.

To create the other forty puzzles, I used a different strategy: instead of generating random cages, I arranged them in fixed patterns and only generated random digits, targets, and op-codes. Here is the type of puzzle you can expect:

These puzzles are in most (but not all) cases more difficult than the random ones. In fact some of them are quite diabolical. The first couple of patterned puzzles are easier than those that follow. Otherwise, the difficulty of the puzzles varies in no particular order.

Of the pattern-puzzles, I solved those numbered from 61 to 98. I haven't solved puzzle 99 but I believe it should be possible to complete it without having to guess (which I never do). Puzzle 100 is a different type of challenge: it admits two solutions, which differ in three cages. I could have removed the ambiguity by splitting one of affected cages, but I thought you might like to check it out, just for fun.

In case you are wondering, the shading of patterned CalcuDokus serves no practical purpose. It’s only there because it makes them prettier.

## Thursday, November 15, 2012

### How to calculate the twin paradox

The Web is full of pages about Special Relativity and how it is responsible for slowing clocks and creating the twin paradox. But what if a star ship accelerates during the first half of its journey and slows down during the second half?

WAIT A MINUTE! Shouldn’t we switch to general relativity when dealing with accelerated systems? Not necessarily. If you accelerate and decelerate along a straight trajectory that joins two star systems and ignore the curvature of space caused by other objects, you are fine with special relativity.

This article tells you how to calculate the time spent by a subluminal (i.e., no warp drives!) star ship constantly accelerating half of the way towards its destination and then constantly decelerating during the second half of its voyage. Its purpose is to support Science Fiction writers who need to write about interstellar travel. I adapted the formulae from an article from the University of California Riverside and, for fun, I re-obtained them from the standard Lorentz transformations for length and time. Initially, I thought I would also explain how it is done, but it would have been a bit too complicated for most people. If you are curious, I found a paper from the University of Leipzig and another article from UCR to be useful.

First of all, let’s define some terminology:
• ‘a’ is the acceleration of the ship measured on the ship itself. Technically called the proper acceleration of the ship, which is the acceleration felt by the passengers. That is, what an accelerometer placed on the ship will measure.

• ‘D’ is the distance between the point of departure and point of arrival, measured when the ship is moving at a speed much lower than the speed of light and with its engines off. Basically, you can take it as the distance we would measure from Earth.

• ‘T’ is the time needed by the ship to make its journey, as measured on Earth. Earth orbits the Sun at 30km/s and the Sun moves at 370 km/s with respect to the cosmic microwave background. But we can ignore these speeds, because they only represent some 0.1% of the speed of light. On Earth, we are also subjected to its gravity and both Earth and the Sun move on curved trajectories, but these accelerations can also be ignored for our purposes. I just read that special-relativity effects slow down the clocks on GPS satellites (orbiting at 20,000km above sea level and travelling at one orbit per 12 hours, or 3.83km/s) by 7μs/day, while general-relativity effects (Earth’s gravitational force is much weaker up there) speed them up by 45μs/day.

• ‘t’ is the time needed by the ship to make its journey, as measured on the ship.

Here we go. Let’s start with the time measured on Earth.  This is given by:

T = 2 sqrt[(D/2/c) 2 + D/a]

To make our life easier, we will measure time in y (year), distances in ly (light year, the distance light covers in one year), and speeds as fractions of c (the speed of light ~300,000km/s). In this units, g (gravitational acceleration on Earth’s surface, 9.81 m/s2) turns out to be 1.03 ly/y2. With this choice of units, c disappears from the above formula, because c = 1.

For example, let’s suppose that we want to reach Proxima Centauri, the nearest star to our solar system (4.24 ly) and that our ship can sustain the acceleration of 0.1g. For the people left back on Earth, the journey will take:

T = 2 * sqrt[(4.24/2) 2 + 4.24/(0.1 * 1.03)] = 13.51y

With an acceleration of 1g (ten times higher), still from the point of view of Earth-bound people, the journey would take 5.87y (you only need to remove the 0.1 from the above expression).

The time measured on the ship is given by:

t = c / a * 2 * arcsinh[a*T/c/2]

With c = 1, the formula becomes:

t = 2 * arcsinh[a*T/2] / a

arcsinh is the inverse function of the hyperbolic sine. You’ll probably find it in Excel (haven’t checked). I have it in the calculator application on my Mac when I set it to scientific mode.

So, how older do the passengers of our ship become when they travel to Proxima at 0.1g and 1g? You only need to plug a and T into the formula and obtain 12.61y and 3.55y.

Not a big deal, is it? In case you are wondering, the top speed, when the ship is half a way to Proxima and switches from 1g of acceleration to 1g of deceleration, is given by:

v = a* T / 2 / sqrt[1 + (a*T/2/c) 2] = 1.03 * 5.87 / 2 / sqrt[1 + (1.03*5.87/2) 2] = 0.95c

If you go to Tau Ceti, a star similar to ours that is 11.9 ly away, you get, for 1g acceleration:

T = 23.98y
t = 6.23y
v = 0.9967c

Now the differences become more significant. Still, you would have imagined a more dramatic difference, wouldn’t you? I did.

OK. Let’s look at the planet HD 40307g. It is the latest Earth-like planet discovered. It might have a gravity twice as strong as Earth’s, but it orbits a star slightly cooler than ours with a 200-day period. It also seems that it rotates on its axis, which would imply a day-and-night cycle. It could have liquid water and be able to sustain life. Its distance from us is 42 ly.

T = 43.90y
t = 7.40y
v = 0.9990c

Well, here the twin paradox is definitely dramatic. After a round trip, the twin on Earth would be 2 * (43.9 – 7.4) = 73y older.

Now, what type of propulsion could possibly accelerate a ship at 1g for more than seven years? You tell me!

## Monday, November 12, 2012

### Misunderstood Science: A question of probability

Probability and statistics are very confusing. Most people think they are self evident and consider them easy to handle, at least in everyday’s life. But they are wrong. For starters, how many of you could state the difference between probability and statistics?

No?

OK. Here it is: Probabilities are decided in advance and have to do with predicting outcomes; statistics are concerned with inferring probabilities based on observed outcomes.

For example, if you have a six-faced die and state that each face will come up on average once every six throws, you are talking about probabilities: you estimate probabilities in advance with a mathematical formula and use them to predict what you will get in practice.

If, on the other hand, throw a six-faced die 600 times and count how many times each face comes up in an attempt to determine how probable they are, you are doing statistics. Obviously, statistics cannot ever be an exact science.

For one thing, no die can be perfectly balanced. Even if you started with a perfectly balanced die (and you tell me how you would determine that!), you couldn’t keep it that way, because with each throw imperceptible abrasions would remove tiny particles (perhaps just atoms) from one or more faces. All in all, if you throw any die enough times, you will discover that some faces come up, on average, more often than others.

But even with an ideal, perfectly balanced die (which, I repeat, is a physical impossibility), you cannot expect to get all faces exactly the same number of times. It is theoretically possible but, the higher the number of throws, the less likely it is. If you throw a die, say, 600 times, I bet you a thousand dollars against ten that you will spend the rest of your life trying to get 100 1s, 100 2s, etc. (I’ll settle the matter with your heirs)

How do you calculate a probability? Conceptually, it is simple: The probability of an outcome is given by the number of ways in which you can obtain that outcome divided by the total number of ways in which you can obtain all possible outcomes. That’s why it is easy to estimate that the probability of, say, a 5 when throwing a die is 1/6 (~16.7%), or the probability of head when throwing a coin is 1/2 (50.0%).

FYI, statisticians call the set of all possible outcomes the sample space. This is a bit twisted, because sample is a statistical term, while sample space refers to the calculation of probabilities,
but who says that scientists are always consistent?

Anyhow, the concept of sample space and the above definition of probability lets you answer questions like: what is the probability of getting a 10 if I throw two dice?

The size of the sample space is 36, because you can get 6 possible values with each dice, and they are independent from each other. The possible ways in which you can obtain a 10 are: (4,6), (5,5), and (6,4). As a result, the probability of obtaining a 10 is 3/36 (~ 8.3%). As a comparison, you can obtain a 7 with (1,6), (2,5), (3,4), (4,3), (5,2) and (6,1), which results in a probability of 6/36 (~16.7%).

Everything clear? Let’s check it out with a fun problem.

I place a ten-dollar bill in one of three identical boxes. Then, while you keep your eyes closed, I move them around so that I still know where the money is but you lose track of it. You have to choose one of the boxes; if it is the box with the money, the ten dollars are your. Clearly, you have a probability of 1/3 (or ~33.3%) to win. You make your choice by placing your hand on one of the boxes. But, before you can open your box, I open one of the other two boxes and show you that it is empty. I then ask you whether you want to stick to your original choice or switch to the other box that is still unopened. What do you do and why?

Obviously, you want to maximise the probability of winning. The questions you need to answer are: does it matter whether you keep the box you initially chose or you switch to the other box that is still unopened? And if it does matter, are you more likely to win if you keep the original box or if you swap it for the other one?

The answer seems obvious: there are two boxes and only one contains a reward. As there are no reasons for preferring either box, it is irrelevant which one you choose. They both have a 50/50 chance of being the winning one.

Or not?

Well, ... no. You are better off switching boxes, because the other unopened box is more likely to contain the ten-dollar bill than the one you initially chose.

Surprised? :-) Let’s see...

What is the probability that you chose the winning box? As I already said: 1/3. If you keep the box, you also keep the 33.3% chance of winning.

And what is the probability that the money is not in the box you chose? Obviously, 2/3. But if it isn’t, as I have already opened one of the two other boxes and showed to you that it was empty, you must conclude that the money is in the remaining box. No doubt about that.

In conclusion, if you stick with your original choice, you have 1/3 probability of winning, but if you switch boxes, you have a 2/3 probability of winning. Twice as high!

Where is the trick?

There is no trick. The whole story appears illogical only because of a widespread fallacy incurred by many people when thinking about probabilities. For probabilities to be equally spread among different outcomes, the possible outcomes must be independent from each other. In our game, they initially were independent, but ceased to be so when I opened one of the boxes. This is because I knew that the box was empty. This made the content of the third box no longer independent. If I had opened one of the boxes without knowing whether it was empty or not, the probability of finding the money in either your box or in the third box would have been equally spread at 50/50, as you probably thought.

If you are not convinced, think that if I had opened one of the two boxes without knowing that it was empty, I would have had 1/3 of probability of opening the winning box, exactly the same probability you had when choosing your box. But if that had not happened, and I had opened an empty box without knowing in advance that it was empty, I would have not introduced any dependency, because opening that box would have not said anything about the third box.

Amazing, isn’t it? Martin Gardner once said: in no other branch of mathematics is it so easy for experts to blunder as in probability theory. Imagine for non-experts...

## Sunday, November 4, 2012

### How can people ignore a grunting pig?

A few days ago, I got as a present the rubber pig you can see in the following image:

Walking in Manuka and Kingston, two suburbs of Canberra, I often made the pig, which is about 20 cm or 8" long, grunt towards the people I encountered.  Some were amused, but most simply ignored it.  We live in a world in which most people don’t even notice a cute grunting pig.  How sad...