Puzzle procrastination: perplexing probabilities part II

A while ago I set some probability puzzles. If you’ve not yet pondered them, give them a whirl now. It’s OK, I’ll wait… All done? Final answer?

1 Girls, boys and doughnuts

We know that Laura has two children. There are four possibilities: two girls (\mathrm{GG}), a boy and a girl (\mathrm{BG}), a girl and a boy (\mathrm{GB}) and two boys (\mathrm{BB}). The probability of having a boy is almost identical to having a girl, so let’s keep things simple and assume that all four options have equal probability.

In this case, (i) the probability of having two girls is P(\mathrm{GG}) = 1/4; (ii) the probability of having a boy and a girl is P(\mathrm{B,\,G}) = P(\mathrm{BG}) + P(\mathrm{GB}) = 1/2, and (iii) the probability of having two boys is P(\mathrm{BB}) = 1/4.

After meeting Laura’s daughter Lucy, we know she doesn’t have two boys. What are the probabilities now? There are three options left (\mathrm{GG}, \mathrm{GB} and \mathrm{BG}), but they are not all equally likely. We’ve discussed a similar problem before (it involved water balloons). You can work out the probabilities using Bayes’ Theorem, but let’s see if we can get away without using any maths more complicated than addition. Lucy could either be the elder or the younger child, each is equally likely. There must be four possible outcomes: Lucy and then another girl (\mathrm{LG}), another girl and then Lucy (\mathrm{GL}), Lucy and then a boy (\mathrm{LB}) or a boy and then Lucy (\mathrm{BL}). Since the sex of children are not linked (if we ignore the possibility of identical twins), each of these are equally probable. Therefore, (i) P(\mathrm{GG}) = P(\mathrm{LG}) + P(\mathrm{GL}) = 1/2; (ii) P(\mathrm{B,\,G}) = P(\mathrm{LB}) + P(\mathrm{BL}) = 1/2, and (iii) P(\mathrm{BB}) = 0. We have ruled out one possibility, and changed the probability having two girls.

If we learn that Lucy is the eldest, then we are left with two options, \mathrm{LG} and \mathrm{LB}. This means (i) P(\mathrm{GG}) = P(\mathrm{LG}) = 1/2; (ii) P(\mathrm{B,\,G}) = P(\mathrm{LB}) = 1/2, and (iii) P(\mathrm{BB}) = 0. The probabilities haven’t changed! This is because the order of birth doesn’t influence the probability of being a boy or a girl.

Hopefully that all makes sense so far. Now let’s move on to Laura’s secret society for people who have two children of which at least one is a girl. There are three possibilities for the children: \mathrm{GG}, \mathrm{BG} or \mathrm{GB}. This time, all three are equally likely as we are just selecting them equally from the total population. Families with two children are equally likely to have each of the four combinations, but those with \mathrm{BB} are turned away at the door, leaving an equal mix of the other three. Hence,  (i)  P(\mathrm{GG}) = 1/3; (ii) P(\mathrm{B,\,G}) = P(\mathrm{BG}) + P(\mathrm{GB}) = 2/3, and (iii) P(\mathrm{BB}) = 0.

The probabilities are different in this final case than for Laura’s family! This is because of the difference in the way we picked are sample. With Laura, we knew she had two children, the probability that she would have a daughter with her depends upon how many daughters she has. It’s more likely that she’d have a daughter with her if she has two, than one (or zero). If we’re picking families with at least one girl at random, things are different. This has confused enough people to be known as the boy or girl paradox. However, if you’re careful in writing things down, it’s not too tricky to work things out.

2 Do or do-nut

You’re eating doughnuts, and trying to avoid the one flavour you don’t like. After eating six of twenty-four you’ve not encountered it. The other guests have eaten twelve, but that doesn’t tell you if they’ve eaten it. All you know is that it’s not in the six you’ve eaten, hence it must be one of the other eighteen. The probability that one of the twelve that the others have eaten is the nemesis doughnut is P(\mathrm{eaten}) = 12/18 = 2/3. Hence, the probability it is left is P(\mathrm{left}) = 1 - P(\mathrm{eaten}) = 1/3. Since there are six doughnuts left, the probability you’ll pick the nemesis doughnut next is P(\mathrm{next}) = P(\mathrm{left}) \times 1/6 = 1/18. Equally, you could have figured that out by realising that it’s equally probable that the nemesis doughnut is any of the eighteen that you’ve not eaten.

When twelve have been eaten, Lucy takes one doughnut to feed the birds. You all continue eating until there are four left. At this point, no-one has eaten that one doughnut. There are two possible options: either it’s still lurking or it’s been fed to the birds. Because we didn’t get to use it in the first part, I’ll use Bayes’ Theorem to work out the probabilities for both options.

The probability that Lucy luckily picked that one doughnut to feed to the birds is P(\mathrm{lucky}) = 1/12, the probability that she unluckily picked a different flavour is P(\mathrm{unlucky}) = 1 - P(\mathrm{lucky}) = 11/12. If we were lucky, the probability that we managed to get down to there being four left is P(\mathrm{four}|\mathrm{lucky}) = 1, we were guaranteed not to eat it! If we were unlucky, that the bad one is amongst the remaining eleven, the probability of getting down to four is P(\mathrm{four}|\mathrm{unlucky}) = 4/11. The total probability of getting down to four is

P(\mathrm{four}) = P(\mathrm{four}|\mathrm{lucky})P(\mathrm{lucky}) + P(\mathrm{four}|\mathrm{unlucky})P(\mathrm{unlucky}).

Substituting in gives

\displaystyle P(\mathrm{four}) = 1 \times \frac{1}{12} + \frac{4}{11} \times \frac{11}{12} = \frac{5}{12}.

The probability that the doughnut is not left is when there are four left is

\displaystyle P(\mathrm{lucky}|\mathrm{four}) = \frac{P(\mathrm{four}|\mathrm{lucky})P(\mathrm{lucky})}{P(\mathrm{four})},

putting in the numbers gives

\displaystyle P(\mathrm{lucky}|\mathrm{four}) = 1 \times \frac{1}{12} \times \frac{12}{5} = \frac{1}{5}.

The probability that it’s left must be

\displaystyle P(\mathrm{unlucky}|\mathrm{four}) = \frac{4}{5}.

We could’ve worked this out more quickly by realised that there are five doughnuts that could potential be the one: the four left and the one fed to the birds. Each one is equally probable, so that gives P(\mathrm{lucky}|\mathrm{four}) = 1/5 and P(\mathrm{unlucky}|\mathrm{four}) = 4/5.

If you take one doughnut each, one after another, does it matter when you pick? You have an equal probability of each being the one. The probability that it’s the first is

\displaystyle P(\mathrm{first}) = \frac{1}{4} \times P(\mathrm{unlucky}|\mathrm{four}) = \frac{1}{5};

the probability that it’s the second is

\displaystyle P(\mathrm{second}) = \frac{1}{3} \times \frac{3}{4} \times P(\mathrm{unlucky}|\mathrm{four}) = \frac{1}{5};

the probability that it’s the third is

\displaystyle P(\mathrm{third}) = \frac{1}{2} \times \frac{2}{3} \times \frac{3}{4} \times P(\mathrm{unlucky}|\mathrm{four}) = \frac{1}{5},

and the probability that it’s the fourth (last) is

\displaystyle P(\mathrm{third}) = 1 \times \frac{1}{2} \times \frac{2}{3} \times \frac{3}{4} \times P(\mathrm{unlucky}|\mathrm{four}) = \frac{1}{5}.

That doesn’t necessarily mean it doesn’t matter when you pick though! That really depends how you feel when taking an uncertain bite, how much you value the knowledge that you can safely eat your doughnut, and how you’d feel about skipping your doughnut rather than eating one you hate.

Equation etiquette

Mathematics can be beautiful. Equations are an important component of technical writing, but getting their presentation correct can be tricky. There are many rules about their formatting, and these can seem somewhat arbitrary. Just like starting with the outermost knife and fork at a fancy dinner, or passing the port to the left, these can seem rather ridiculous when you first learn them, but there is some logic to them. Here, I give a short guide to the proper etiquette of including equations in your writing.

0 Make introductions

The simplest rule: explain what your symbols mean. The dinner-party equivalent would be to introduce your guests, so that everyone knows whom they have to attempt conversation with. For an equation to be of any use, people need to know what it means. This can be especially important as some symbols are commonly used for different quantities. Introduce your readers to your symbols promptly, so that the equation makes sense. For example,

“Ohm’s law says that the voltage across a resistor is

V = IR,

where I is the current flowing through the resistor and R is the resistance of the resistor.”

Here, I left the definition of V implicit, but hopefully everyone’s now acquainted, so we can chat (probably about electronics) until the soup is ready.

Depending on your audience, there are some things you can get away without introducing. The mathematical constant \pi is always referred to as pi, so you can usually skip the definition of it being the ratio of a circle’s circumference to its diameter. \pi is the superstar guest that needs no introduction. If you are using the symbol for something else, make sure to make that clear!

Pi pie!

Pi pie! Perfect for any mathematical dinner party. Technically, there’s 2\pi of pie here. Credit: Tasty Retreat

While not as famous as \pi, the mathematical constants e, the base of the natural logarithm, and i = \sqrt{-1}, the imaginary unit, can sometimes be left undefined. They are dinner-party regulars, so as long as your guests have been invited along a few times before, they should have met. Unlike \pi, e and i are frequently used for other quantities, so if there’s chance of there being some confusion, play it safe and make the introduction (remember, no-one like having to ask the names of people that they’ve met before).

Finally, some of the fundamental physical constants like the speed of light c, the Newtonian constant G, Boltzmann’s constant k and the reduced Planck constant \hbar, can sometimes be left unintroduced if writing for professional physicists. They are guests that went to university together, so you can assume they know each other. If there is any chance of confusion though, make sure to introduce them. Try to never use a symbol for any of the constants that is not their usual one, that’s like giving a guest a new nickname for the purpose of the party. It will lead to all sorts of confusion, which might be amusing in a sit-com, but less so in scientific writing

Never use the same symbol for two different quantities. Just like having a seating plan with two identical names, this leads to confusion, arguments over who gets to sit next to the awesome physicist, and people being stabbed with forks. Using subscripts or superscripts, or a different font are common ways of avoiding a clash.

1 Punctuate properly

Equations should form a central component of your text. They are part of your sentences. Accordingly, they should be punctuated properly so that they make sense. This is like chewing with your mouth closed: no-one likes to see a mess.

It can be hard to put equations into words, to figure out where to put punctuation. However, they can usually be read as “left-hand side equals right-hand side”. Here, “equals” is a verb. Often an equation will need to be followed by comma, as above. Missing out punctuation is especially obvious when the equation comes at the end of a sentence and there’s no full stop.

Starting a sentence with an equation is a little weird, like serving the sweet before the soup. It throws people off. This is because we are used to scanning for upper-case letters to find the start of sentences, and starting with a mathematical symbol throws this off. This makes it harder for the reader to break-up the text and quickly understand your points.

Usually it is easy to reword to avoid starting a sentence with mathematics, consider

E =mc^2 is the most famous equation in physics. c is the speed of light in a vacuum and E is the energy equivalent of mass m.”

can be switched to

“The most famous equation in physics is E = mc^2. This explains the equivalence of energy E and mass m, converting using the speed of light c.”

2 Fonts, roman, italic

Lend me you ears, I come with some of the finer details, like which fork to use. Variables are typeset in italics. This makes it easy to spot with letters are mathematical quantities and which are just plain text: a is a variable and a is just a short word.

Not everything that appears in an equation should be italicised. Numbers; operators like +, - and \times, and brackets (\ldots) are left as they are. These are always just themselves, so there’s no need to italicise, they are left roman (upright).

Function names, when more than one letter, are not italicised. For example \sin, \log or \min. This lets you know that these letters can’t be broken up, they come as a single unit. For example

\displaystyle \frac{sinx}{cosx} = \frac{in}{co},

but

\displaystyle \frac{\sin x}{\cos x} = \tan x.

Related to this, is the question of whether you should italicised the differential \mathrm{d}? I like to have it roman so it’s

\displaystyle \frac{\mathrm{d}x}{\mathrm{d}y} \quad and \quad \int f(x)\, \mathrm{d} x.

I think this makes it clear that the infinitesimal element \mathrm{d}x can’t be broken up (you can’t cancel \mathrm{d}). However, this is not universal, so I think this is much like whether you should prod or crush the peas onto your fork.

Subscripts and superscripts often lead to confusion. If they are part of a variable’s name, should they always be italicised? The answer is no: they should be treated as if they were in the main text. If I want to specify the area of a circle, it would be A_\mathrm{circle}, as circle is just a regular word. If I want to specify the coordinates of point \mathrm{P}, they are (x_\mathrm{P},\,y_\mathrm{P}), as \mathrm{P} is the name of the point, not a variable. If I wanted to talk about heat capacity, then the heat capacity at constant volume is C_V and the heat capacity at constant magnetic flux density is C_B because I’m using V and B to specify the volume and magnetic field respectively.

All this seems to make sense to me. It might seem strange that there’s a specific item of cutlery for each course, but it is easier to cut a steak with a steak knife than a butter knife, so there may be some logic to it. Similarly, the typesetting of maths does convey some meaning.

Sadly, there is a common exception to the rule, upper-case Greek letters are often not italicised, but are left upright, e.g. \Theta. (Lower-case Greek letters are italicised, as are our Latin upper-case letters). It could be that this gives a way of distinguishing between an upper-case beta \mathrm{B} and a capital B, chi \mathrm{X} and X, etc. However,  I think this is just because they look odd in some fonts. Italicising them wouldn’t be wrong. (Although, the summation symbol \sum and product symbol \prod are operators, and so should never be italicised).

3 Laying out units

Forgetting to include units is much like forgetting your trousers at a dinner party. It’s a definite faux pas, not to mention painful if you drop some of that hot soup. However, unlike the wearing of trousers, there is an international guideline on how to correctly use units. Units appear after a number separated by a small non-breaking space, e.g. x = 2.3~\mathrm{m}. The space needs to be non-breaking so that it’s never separated from the number, which would be painful.

Groundskeeper Willie

Trousers are not standardised, but units are! The Springfield Police are shocked when Willie forgets his. Credit: Fox

You may have noticed that units are not italicised. This makes them readily identifiable, and also avoids any confusion that a millimetre is the same as a square metre or that one hertz per henry could be z. Not italicising units means there’s a clear difference between T = 5~\mathrm{s} and T = 5s. The first indicates a time of five seconds, the second that T is five times s, whatever that might be. We can also write things like s = 5~\mathrm{s} without them being nonsense.

When making compound units, use negative powers rather than a slash so there are no ambiguities. It’s difficult to figure out \mathrm{m/s^2/kg^3}, but \mathrm{m~s^{-2}~kg^{-3}} is clear. You don’t want everyone pondering if you’ve accidentally put your trousers on back-to-front.

Finally, when plotting graphs, units should be included in the axis labels. I like to think of graphs just being of pure, dimensionless numbers, hence I need to divide out the units, e.g. T/~\mathrm{s} for time in seconds or C_V/(\mathrm{J~K^{-1}}) for heat capacity.

4 Use the right symbol for the job

Trying to eat your soup with your crab fork is not going to end well. You should always use the right tool for the job. When writing maths, this means using the correct symbol. The multiplication sign \times is not an x, and the minus sign - is not a hyphen.

5 Close your brackets

No parsing scripts should be harming in the reading of this

Pure evil. Credit: xkcd

To close, some tips on brackets. Brackets should always come in an (equally-size) pair. They should be large enough to enclose their contents. When eating, you should cut your food up into bite-size pieces, you can’t chop up equations in the same way, so instead you resize the brackets.

When nested brackets, use different types of brackets so it’s clear which term ends where. It’s usual to start with parentheses (\ldots), then use square brackets [\ldots], and then braces \{\ldots\}. Unlike with cutlery, you start inside and work your ways out. For example, making something up,

\displaystyle \exp\left\{-(1 + 2\xi)\left[(\xi - 1)^2 + \cos \left(\frac{\pi \xi}{2}\right)\right]^{-1/2}\right\}.

If you need more than three levels, you usually cycle round again.

There are a few cases where a particular type of bracket is used. Angle brackets \langle\ldots\rangle are often used for an average. Square brackets are often used to enclose the argument of a functional. Curly braces are often used for limits, \lim_{x\,\rightarrow\,0} \{\mathrm{sinc}\,x\} = 1, or Fourier transforms, \mathscr{F}_k\{f(x)\} = \tilde{f}(k). The important thing is to be clear, to make it easy for the reader to distinguish which brackets matches to which other.

That brings us to the end. We’ve closed all our brackets, and put our knife and fork together on our plate. Presenting equations clearly, like writing clearly, makes writing easy to understand. Paying attention to the details, making sure that you dot all your is and cross all your \hbars, creates a good impression, it shows you’re careful and that you care about your work. You may even get invited out to dinner again.