Blog

The power of simulation: birthday paradox

The birthday paradox goes… in a room of 23 people there is a 50-50 chance that two of them share a birthday.

OK, so the first step in introducing a paradox is to explain why it is a paradox in the first place. One might think that for each person, there is 1/365 chance of another person having the same birthday as them. Indeed, I can think of only one other person I’ve met that has the same birthday as meand he is my twin brother! Since I’ve met far more than 23 people, how can this be true?

This reasoning is flawed for several reasons, the first of which is that the question wasn’t asking about if there was another person in the room with a specific birthdayany pair of people (or more!) can share a birthday to increase the chances of the statement being true.

The complete answer gets heavy into the math, but I want to show you how to convince yourself it is true by simulating the experiment. Simulation is programming a computer or model to act as if the real thing was happening. Usually, you set this up so that the cost of simulation is much less than doing the actual thing. For example, putting a model airplane wing in a wind tunnel is a simulation. I’ve simulate the birthday paradox in a computer programming language called Python and this post is available in notebook-style here. Indeed, this is much easier than being in a room with 23 people.

Below I will not present the code (again, that’s over here), but I  will describe how the simulation works and present the results.

The simulation

Call the number of people we need to ask before we get a repeated birthday n. This is what is called a random variable because its value is not known and may change due to conditions we have no control over (like who happens to be in the room).

Now we simulate an experiment realising a value for n as follows.

  1. Pick a random person and ask their birthday.
  2. Check to see if someone else has given you that answer.
  3. Repeat step 1 and 2 until a birthday is said twice.
  4. Count the number of people that were asked and call that n.

Getting to step 4 constitutes a single experiment. The number that comes out may be n = 2 or n = 100. It all depends on who is in the room. So we repeat all the steps many many times and look at how the numbers fall. The more times we repeat, the more data we obtain and the better our understanding of what’s happening.

Here is what it looks like when we run the experiment one million times.

exponemil
Simulating the birthday paradox. On the horizontal axis is n, the number of people we needed to ask before a repeated birthday was found. We did the experiment one million times and tallied the results.

So what do all those numbers mean? Well, let’s look at how many times n = 2 occurred, for example. In these one million trials, the result 2 occurred 2679 times, which is relatively 0.2679%. Note that this is close to 1/365 ≈ 0.274%, which is expected since the probability that the second person has the same as the first is exactly 1/365. So each number of occurrences divided by one million is approximately the probability that we would see that number in a single experiment.

We can then plot the same data considering the vertical axis the probability of needing to see n people before a repeated birthday.

prob
Same as the previous plot but now each bar is interpreted as a probability.

Adding up the value of each of these bars sums to 100%. This is because one of the values must occur when we do an experiment. OK, so now we can just add up these probabilities starting at n = 2 and increasing until we get to 50%. Visually, it is the number which splits the coloured area above into two equal parts. That number will be the number of people we need to meet to have a 50-50 shot at getting a repeated birthday. Can you guess what it will be?

Drum roll… 23! Tada! The birthday paradox simulated and solved by simulation!

But, wait! There’s more.

What about those leap year babies? In fact, isn’t the assumption that birthdays are equally distributed wrong? If we actually tried this experiment out in real life, would we get 23 or some other number?

Happily, we can test this hypothesis with real data! At least for US births, you can find the data over at fivethirteight’s github page. Here is what the actual distribution looks like.

dist_birth.png
Distribution of births in US from 1994-2014, by day of year.

Perhaps by eye it doesn’t look too uniform. You can clearly see 25 Dec and 31 Dec have massive dips. Much has been written about this and many beautiful visualizations are out there. But, our question is whether this has an effect on the birthday paradox. Perhaps the fact that not many people are born on 25 Dec means it is easy to find a shared birthday on the remaining days, for example. Let’s test this hypothesis by simulating the experiment with the real distribution of birthdays.

To do this, we perform the same 4 steps as above, but randomly sampling answers from the actual distribution of birthdays. The result of another one million experiments is plotted below.

truehist.png
Simulating the birthday paradox on the true distribution of births. On the horizontal axis is n, the number of people we needed to ask before a repeated birthday was found. We perform the experiment one million times and tallied the results.

And the answer is the same! The birthday paradox persists with the actual distribution of birthdays.

Nerd sniping

The above discussion is very good evidence that the birthday paradox is robust to the actual distribution of births. However, it does not constitute a mathematical proof. An experiment can only provide evidence. So I will end this with a technical question for those mathematical curiosos out there. (What I am about to do is also called Nerd Sniping.)

Here is the broad problem: quantify the above observation. I think there is more than one question here. For example, it should be possible to bound the 50-50 threshold as a function of the deviation from a uniform distribution.

(Cover image credit: Ed g2s, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=303792)

The power of silence

It is too easy to get trapped into the mentality that—because you know better—you can instantly fix a child’s problem. So why is it that resistance follows? Hint: it’s because you are not listening.

Recently I decided to take the plunge into audiobooks. Since this was a new venture for me, I decided also to listen to something I wouldn’t otherwise read: a parenting book. I’m not implying that I’m a perfect parent by thatI’ve just been blessed by a great partner and four amazing children, such that I haven’t felt the need to seek unnecessary advice.

Whether or not you think you are in the same boat, you should definitely pick up a copy of How to Talk so Your Kids will Listen and Listen so Your Kids will Talk written by Adele Faber and Elaine Mazlish. Now, at this point you might be sarcastically saying, “Thanks for alerting us to the existence of a 30 year old parenting book in its 13th edition that has been referred to as the parenting bible.” But, this post is for those who don’t frequent self-help blogs and the parenting aisle of the bookshop; you might think you have a great relationship with your kidsthis book will make it better.

A comment about the audiobook

Before I continue, let me remind you that I listened to the audio version of the book. I have mixed, but still overall positive, feelings about this. First, there are plenty of cartoons in the physical book which obviously don’t translate to audio. I honestly didn’t notice this. Second, there are lots of exercises and places where you are asked to write things down. This is a bit awkward if you are listening to the book while being active. On the other hand, it is narrated by Susan Bennett, otherwise known as Siri. She does an absolutely amazing job capturing the emotion of the authors and, most importantly, the constant dialog in the book between parent and child. In any case, the content is well worth it. The remainder of this discussion will be about the content of the audiobook.

Nitpicking

I noticed that much of dialog in the book was dated in terms of language and subject matter. For example, a situation considered in the book was a child who borrowed and scratched a father’s compact disc. I mean, does anyone even own CD’s anymore? Luckily, this is more of a nostalgic amusement than a distraction.

I also didn’t like how the anniversary edition involved appendices of additions rather than a more streamlined approach. It felt a bit lazy and tacked on. In any case, the additional content was a useful addition to an otherwise great book.

Examples, examples, examples

A large chunk of How to Talk consists of real-life example dialogue between parent and child. These are invaluable. Often, the advice seems obvious in hindsightvalidate feelings, for example. But, it’s only after hearing the examples when you really see where improvement can be made. The examples usually begin with a fictitious unhelpful response from the parent, followed by a helpful response. Let me give you an example that actually happened to me when I tried to use the skills on my own children after reading the first chapter: “Helping Children Deal with Their Feelings.” My strategy was to default to silent acknowledgment whenever I couldn’t quickly find an appropriate response. 

Situation 1: Child (7) is asked to practice math exercises. After doing a few, she becomes bored and says, “I can’t do it.” Clearly, she can. Here is a typical way this would play out.

Child: I can’t do it.
Parent: Yes you can.
Child: I can’t. I don’t know how.
Parent: Well, you are not leaving the table until it is done.
Child (now crying): But I want to watch a movie!
Parent (voice raised): No movies until you are done all your homework!
Child: You’re mean!

And there is no end to the cycle. But, here is how it actually went:

Child: I can’t do it.
Parent: You feel that question is too hard for you?
Child: Yeah.
Parent: Hmm…
Child: [silence]
Parent: [silence]
Child: I think the answer is 17.

I couldn’t believe how well silence works for acknowledging feelings. Here is another example.

Situation 2: Child (3) is struggling to get his footwear on. He is frustrated that the sandal won’t fit on the wrong foot. Here is the typical way this would have gone.

Child (clearly frustrated): I can’t get it on!
Parent: That’s because you are putting it on the wrong foot.
Child: NO! It doesn’t fit!
Parent: Would you like me to do it for you?
Child: No!
Parent: [forces sandal on correct foot]
Child: [cries]

Here is how it actually went:

Child (clearly frustrated): I can’t get it on!
Parent: I see you are frustrated with that sandal.
Child (calmer): It doesn’t fit.
Parent: That can be so frustrating!
Child: [silence]
Parent: [silence]
Child (probably knowing all along): It’s the wrong foot.
Parent: [silence]

And he took it off the wrong foot and put it on the correct foot!

Bottom line

How to Talk contains seven chapters, the last being titled, “Putting it All Together.” But, to my mind, the first chapter contains the key insights to a better emotional relationship with my children. In the past, I’ve tried to avoid situations like those exemplified above. Accepting and dealing with my children’s emotions has not been that difficult because I have been fairly well in tune with them. This meant that I was able to easily anticipate meltdowns and avoid them altogether. For example, if I sensed that my 3 year old was irritable, I would not ask him to put his own shoes on, thereby avoiding the situation.

But protecting the children from their own feelings is not doing them any favors in the long run, and is becoming ever more difficult with a growing family. So, rather than doing the hard work of anticipating and preventing the emotional distress of my children, I’m now trying to acknowledge and accept how difficult it is to become an autonomous little person in a grown-up world.

Milking a new theory of physics

For the first time, physicists have found a new fundamental state of cow, challenging the current standard model. Coined the cubic cow, the ground-breaking new discovery is already re-writing the rules of physics.

A team of physicists at Stanford and Harvard University have nothing to do with this but you are probably already impressed by the name drop. Dr. Chris Ferrie, who is currently between jobs, together with a team of his own children stumbled upon the discovery, which was recently published in Nature Communications*.

sphericalcow2
Image credit: Ingrid Kallick

The spherical theory of cow had stood unchallenged for over 50 yearsand even longer if a Russian physicist is reading this. The spherical cow theory led to many discoveries also based on O(3) symmetries. However, spherical cows have not proven practically useful from a technological perspective. “Spherical cows are prone to natural environmental errors, whereas our discovery digitizes the symmetry of cow,” Ferrie said.

Just as the digital computer has revolutionized computing technology, this new digital cow model could revolutionize innovation disrupting cross-industry ecosystems, or something.

Lead author Maxwell Ferrie already has far-reaching applications for the result. “I like dinosaurs,” he said. Notwithstanding these future aspirations, the team is sure to be milking this new theory for all its worth.

* Not really, but this dumping ground for failed hypesearch has a bar so low you might as well believe it.

No one is going to take you seriously

I make jokes. I do scientist. I make jokes while doing science.

Recently, at the Australian Institute of Physics Congress I presented this poster:

I think it was generally well received. Of course it got lots of double takes and laughs, but was it a good scientific poster? One of my senior colleagues was of mixed minds, eventually concluding with some familiar life advice:

Yes, I admit it is funny. But, eventually it will catch up with you. No one is going to take you seriously. You will not be seen as a serious scientist.

Good—because I am not a serious scientist. I am a (hopefully) humorous scientist, but a scientist nonetheless.

I’m going to get straight to the point with my own advice: avoid serious scientists at all costs. They are either psychopaths or sycophants. I can’t find it in me to be either. So I’ll continue doing science, and having a bit of fun while I’m at it. You only science once, right?

 

My visit to a Chinese kindergarten class

I think this means it went well.

Recently, I had a video chat with the kindergarten class of Dragon Bay Kindergarten in Beijing. It was a lot of fun to see how excited the children and teachers were to read my books. They even had an entire Science Fair based around my Physics for Babies books!

Beijing_babyphys.png

During our video call, the students and teachers asked many questions. I’ve transcribed them here.

Student questions

How can I see atoms in the real world?

We can not see atoms with our eyes. They are too small. We can use other ways to take pictures of atoms. In the labs where I work, physicists shine laser light on the atoms. The electrons take the energy to move up in their energy levels. When they fall back down, they release light that we can see with a camera.

Can you introduce particles and entanglement to us?

Atoms themselves are made of even smaller things called particles. Electrons are one kind of particle. Not all particles make atoms though. Photons, what light is made of, are another kind of particle which is not part of an atom.
Entanglement is tricky to explain in everyday language. It is something we see in the math of quantum physics. Even scientists today argue about how to understand it. But, we can use the math to show us how to build quantum technology where entanglement is used.

What does an atom look like? How are they different?

Electron microscopes take pictures of atoms which look like blurry little balls. Most atoms look the same but some are bigger than others. When electrons move between energy levels, they send out light at very specific colors. Each atom makes a different color, which is how we can tell them apart.

How do you know everything was made by atoms?

We can see them with today’s technology!

How can I touch the atom?

Since everything is made of atoms, you are touching them right now!

Why don’t you wear the clothes of a physicist?

In pictures of scientists, they are often wearing lab coats. In real life, physicists do not wear lab coats. Some work in a lab and others, like me, work in an office with computers and whiteboards.

Teacher questions

What made you think that babies need to learn about quantum entanglement?

A lot of science is a language which we learn by listening and talking to other scientists, just like learning your first language. So, the sooner you start to hear the language, the sooner you will speak it.

Will entangled particles always be measured the same or can they just be influenced?

Entanglement has a quality to it which might not make it perfect. Experimental technology is always a bit unreliable. But perfect entanglement, like that described in the book, means that particles will be measured the same every time.

Do your children like and understand your books?

My children like the books and can often repeat some of the sentences. I talk with them about it, but they will not be doing any quantum physics research yet.

How does your work place look like?

There are labs. Some use lasers which means they must be dark. Some have big refrigerators which keep things really really cold. Above the labs is office space. Here it looks like a regular office, but with whiteboards that have lots of math on them.

How quantum mechanics turned me into a Bayesian

A few elder-statesmen of quantum theory gathered together while a handful of students listened in eagerly. Paraphrasing, one of them—quite seriously—said, “I don’t think any of the interpretations are logically consistent… but there is this ‘transactional interpretation’, where influences come from the future, that might be the only consistent one.” The students nodded their heads in agreement—I walked away.

Bayesianism is (some would say) a radical alternative philosophy and practice for both understanding probability and performing statistical analysis. So, like all young contrarian students of science, I was intrigued when I first found Bayesian probability. But where is the fun in blaming this on my own faults? I’m going to blame someone else—I’m going to blame it on Chris Fuchs.

On two occasions the Perimeter Institute for Theoretical Physics (PI) hosted lectures on the Foundations of Quantum Mechanics. I was lucky enough to be a graduate student in Waterloo at the time. The first, in 2007, was my first taste of the field. It was exciting to hear the experts at the forefront speaking about deep implications for physics andindeed—even the philosophy of science itself. I knew then that this was the area I wanted to work in.

However, I quickly became disillusioned. The literature was plagued by lazy physicists posing as armchair philosophers. There was no interest in real problems—only the pandering of borderline pseudoscience. It’s no wonder—why bother doing hard work and difficult mathematics when peddling quantum mysticism is what gets you press?

I stayed, though, because there were several researchers at PI who seemed interested in solving real, technical problemsand, they were doing so using techniques from another field I had already worked in: Quantum Information Theory. I learned an immense amount from Robin Blume-Kohout, Rob Spekkens and Lucien Hardy while there, but the one who left a lasting impression was Chris Fuchs.

Before we get to Fuchs, though, let’s back up for a momentjust what is this Quantum Foundations thing, and what has it got to do with Bayesianism? As you know, quantum theory dictates that the world is uncertain. That is, as a scientific theory, it makes only probabilistic predictions. Many of the philosophical problems and misunderstandings of quantum theory can be traced back to this fact. Thus, if one really wants to understand quantum theory, one ought to understand probability first. Easy, right?

Nope. As it turns out, more people argue about how to interpret the seemingly simple and everyday concept of probability than do our most sophisticated and complex physical theory. Generally speaking, there are two camps in the interpretations of probability: frequentists and Bayesians. As noted, every student begins as one of the former. It was in 2010 when my conversion to the latter was complete.

foundations_table.png
Summary of the interpretations of quantum theory.

In 2010, PI hosted its second course on the foundations of quantum theory. This time around I had a few years of experience under my belt and my bullshit detectors were on high alert. My final assignment was to summarize the course, as shown above. The only lectures that didn’t leave me disappointed where Chris Fuchs’. Because I had been reading up on Bayesian probability anyway, his “Quantum Bayesian” interpretation of quantum theory just clicked.

And it wasn’t just about philosophy. Concurrently, I was taking a great course on Stochastic Processes from Matt Scott. Most of this field takes an objective (frequentist) view of probability. Matt was patient with my constant questions on how to phrase the concepts in terms of the subjective Bayesian view. I was starting to feel a bit overwhelmed with the burden of translating everything to the new framework… then it happened.

jh75tdv

The assignment question was as follows: Show that \int_\infty^\infty p(x_2,x_1;t_2-t_1) d_{x_1} = p(x_2;t_2), the simplest case of the Chapman-Kolmogorov equation. What you were supposed to do is use the Markov property, p(x_2,x_1;t_2-t_1) = p(x_2|x_1;t_2-t_1)p(x_1|t_1), and integrate. It was a straightforward, but tedious, calculation. Here is what I wrote: first  p(x_2,x_1;t_2-t_1) = p(x_1|x_2;t_1-t_2)p(x_2|t_2). Since p(x_1|x_2;t_1-t_2) is a probability, it integrates to 1. Done.

This was seen as unphysical because t_1-t_2 is a negative time. So what?I thoughtprobabilities are not physical, they are subjective inferences. If I want to consider negative time to help me do my calculation, so be it. After all, I considered negative money to get me into university. But what I couldn’t believe is how difficult it was to convince others the solution was correct. It was at that moment I realized how powerful a slight change of view can be. I was a Bayesian.

Just what does a postdoctoral theoretical physicist do all day?

Coffee… mostly, I drink coffee.

A kindergartener once asked me, “why don’t you wear science clothes?” I gathered that she meant a lab coat. Then there is the utter surprise my neighbors show when I tell them—yes—I am on my way to work wearing sandals, shorts and a t-shirt. Take a moment and do a google image search of “scientist”. You have to scroll through several pages before you see a person not wearing a lab coat. So if I don’t wear a lab coat while staring into a beaker as if the colorful liquid inside contained a part of my soul, what do I do all day?

Generally speaking, a postdoctoral researcher (postdoc) is someone at a stage in their academic career between a graduate student and a professor. This usually involves traveling around the world working on short-term contracts. In theoretical physics the typical situation is to move several times over a period of 5–10 years before landing a permanent position as a professor or leave academia for an industry job.

While that sounds kind of horrible, as far as responsibilities go, it’s the best job in the world. I have the freedom of a graduate student, but I don’t have to write exams or engage in any of the administrative duties of a professor. I get to focus on my passion: research.

Now, you might be thinking “wait, pictures of physicists still have lab equipment surrounding them. Presumably, instead of beakers, you still have to be doing something technical with your hands.” No. Let me explain. There are two types of physicists: experimental and theoretical. The distinction is easy to make. Experimental physicists (experimentalists) spend at least some of their time in a lab building devices to probe and test hypotheses about the world. Theoretical physicists (theorists) do not. I am one of the latter.

034f6e98174583e154f326dce722c110810ea1487b69fa1d0bc7674545f8b21b.jpg

OK, so I don’t wear a lab coat, I don’t use beakers, I don’t build anything, I don’t even step foot into a lab, what exactly do I do?

What does the internet say:

Theoretical physicists have a fascinating job that combines observation with mathematics in order to create complex formulas that describe the workings of the universe around us.

Not bad, but still not very illuminating in terms of my day-to-day life. In a business sense, I do create products: journal articles. These are usually 5–15 page papers which summarize a successful result, which can takes months to years to obtain. What they do not contain is any semblance of the blood, sweat and tears which make up the chaotic mess that went into them.

This mess can broken down into four tasks:

  1. Discuss problems with colleagues
  2. Perform mathematical calculations
  3. Read journal articles
  4. Write computer software

I don’t do every task every day, but on average my time is about equally spent on each.

piechart_postdoc
A day in the life of a postdoctoral theoretical physicist.

Much of every day is spent discussing problems with colleagues. Sometimes I seek advice on the problems I’m working from a co-worker; sometimes I am providing advice to others; and sometimes I am discussing a problem we are jointly working on. These are often brainstorming session which involve scribbling notes on a whiteboard and plenty of coffee.

Next, I perform mathematical calculations. This involves a lot of paper covered in the kinds of symbols pictured above. You’ll notice there is no arithmetic. These are abstract manipulations of symbols according to some rules. The fun part is that I sometimes get to make the rules! Most of the work done in this category gets trashed due to dead ends or errors and the rest gets heavily compressed if and when a journal article is written.

In order to find out what things others have tried and what techniques I can use to solve a problem, I read journal articles written by other scientists. Finding the right articles is a skill on its own given that over 2.5 million scientific journal articles are written each year. Often I find myself skimming over papers, picking out specific pieces. Occasionally, I am asked by a journal to evaluate the scientific merit of another article. This process is called peer review and could very well be the subject of a future post.

Lastly, there is coding. I write computer software that helps answer the scientific questions I have. For example, with my long-time friend and colleague Chris Granade I co-wrote Qinfer, which is statistical software for debugging small quantum computers. You’ll see examples of this and other software projects in future blog posts.

So there you have it. A day in the life of a postdoctoral theoretical physicist.