charlesreid1.com blog

A Pair of Dice Games (or, Why Chevalier de Méré Lost Money)

Posted in Mathematics

permalink

Here is a nice little problem from Paul Nahin's Will You Be Alive 10 Years From Now?. It is a problem from the 1654 correspondence between Antoine Gombaud (the Chevalier de Méré) and Blaise Pascal - one of the founding episodes of probability theory, dressed up as a gambling puzzle.

(This one lives on our wiki as FMM21, part of our Friday Morning Math Problem series.)

The Two Games

Game 1. You toss a single die \(N_1\) times. What should \(N_1\) be to make the probability of seeing at least one 6 greater than \(\tfrac{1}{2}\)?

Game 2. You toss a pair of dice \(N_2\) times. What should \(N_2\) be to make the probability of seeing at least one double 6 greater than \(\tfrac{1}{2}\)?

In gambling terms, the question is: what is the smallest \(N\) that turns an even-money bet on "at least one 6" (or "at least one double 6") into a bet that favors the gambler rather than the house?

Game 1

Pascal's trick is to count the complement. There are \(6^{N_1}\) ways for the die to land over \(N_1\) tosses, and \(5^{N_1}\) of them have no 6 at all. So

$$ P_1 = 1 - \left(\dfrac{5}{6}\right)^{N_1} $$

We want \(P_1 > \tfrac{1}{2}\), which is easiest to just tabulate:

  • \(N_1 = 1\): \(P_1 = 0.167\)
  • \(N_1 = 2\): \(P_1 = 0.306\)
  • \(N_1 = 3\): \(P_1 = 0.421\)
  • \(N_1 = 4\): \(P_1 = 0.518\)

So \(N_1 = 4\).

Game 2

Same trick with a pair of dice. The probability of a double 6 on a single toss is \(\tfrac{1}{36}\), so the probability of not rolling a double 6 is \(\tfrac{35}{36}\), and

$$ P_2 = 1 - \left(\dfrac{35}{36}\right)^{N_2} $$

Tabulating:

  • \(N_2 = 24\): \(P_2 = 0.491\)
  • \(N_2 = 25\): \(P_2 = 0.506\)

So \(N_2 = 25\).

Gombaud's Mistake

Here is the fun part.

Gombaud believed in strict proportionality. He reasoned that since Game 1 had 6 outcomes per toss and Game 2 had 36 outcomes per toss, the answers should be related by

$$ \dfrac{N_1}{6} = \dfrac{N_2}{36} $$

With \(N_1 = 4\), that gives \(N_2 = 24\). And Gombaud, who was a very careful gambler, actually played this game for money on the belief that \(N_2 = 24\) was the tipping point.

But it turns out that \(N_2 = 24\) gives a probability of \(0.491\), which is just barely on the wrong side of \(\tfrac{1}{2}\). Gombaud noticed, over a large number of games, that he was consistently losing money at \(N_2 = 24\). Being unable to figure out why, he wrote to Pascal.

The intuition that ratios of counts should scale linearly is one of those things that feels obviously true and is very quietly false. The correct answer is off by one - \(N_2 = 25\), not \(24\) - and that one integer of difference was enough to drain the Chevalier's purse.

The Moral

There are two morals, depending on your temperament:

  • If you are a probability theorist, the moral is: complementary events are your friend, and multiplying \(\tfrac{5}{6}\) by itself is a lot easier than enumerating all the ways to see at least one 6.

  • If you are a gambler, the moral is: do not let intuition about ratios substitute for actual arithmetic, and if a French nobleman offers you an even-money bet on rolling a double 6 in 24 throws, take it.

More

Tags:    mathematics    probability    dice    pascal    friday morning math   

Installing LaTeX Packages on macOS: The `~/Library/texmf` Layout

Posted in LaTeX

permalink

Every few years, we find ourselves installing a new LaTeX package on a Mac, and every few years, we find ourselves searching for the same set of directory paths, the same texhash invocation, and the same reminders that the LaTeX package installer is not, in fact, going to create any directories for us.

So this post is here mostly as a note to our future selves.

Where TeX Looks First

We use MacTeX (http://www.tug.org/mactex/), and MacTeX installs its files under /usr/local/texlive/. That is the system-wide texmf tree.

Personal TeX files should not go there. They should go under ~/Library/texmf, which is your user-level texmf tree. When TeX needs to find a file, it looks in ~/Library/texmf/ first, and the system-wide texmf second. So if you drop a modified version of a system file into your user tree, the modified version wins.

The Directory Layout

The folder structure inside ~/Library/texmf should mirror the structure of the system texmf tree. Here is where different kinds of files go:

  • TeX files: ~/Library/texmf/tex (or any subfolder of it)
  • LaTeX files: ~/Library/texmf/tex/latex
  • LyX files: ~/Library/texmf/tex/latex/lyx
  • BibTeX .bib files: ~/Library/texmf/bibtex/bib
  • BibTeX .bst (bib style) files: ~/Library/texmf/bibtex/bst

If any of these directories don't exist, you have to create them. Most TeX or LaTeX installers will not create them for you. Just run

mkdir -p ~/Library/texmf/tex/latex

and you are on your way.

Rehashing After You Add Files

When you drop a new file or folder into the texmf tree, TeX will not find it until you rehash the TeX database. The command is:

texhash ~/Library/texmf

If you don't know where your texmf directories are in the first place, running texhash on its own will update the database and print the paths it found, which is a nice way to discover the layout on any given machine.

Example: The cancel Package

The cancel package is a small package for drawing slashing arrows through terms in equations (nice for "goes to zero" or "goes to infinity" annotations in engineering equations).

Installing it on a Mac is one of the easier cases:

  • Download the package zip
  • Unzip it
  • Drop the .sty file into ~/Library/texmf/tex/latex
  • Run texhash ~/Library/texmf

That's it - no sudo, no system-wide install, no touching /usr/local.

What About Windows?

Use MikTeX: http://miktex.org/. MikTeX has its own package manager and handles most of this automatically. Consider yourself lucky.

When Things Go Wrong: Conflicts With Fink

One historical footgun that we hit years ago, and mention here in case someone else runs into it: if you have Fink installed, Fink may install its own copy of pdftex, and Fink may be putting /sw (or whatever your Fink prefix is) at the front of your $PATH.

If that happens, pdftex from the command line resolves to the Fink version, not the MacTeX version, and things get confusing quickly.

Two fixes:

  1. Stop sourcing /sw/bin/init.sh (or pathsetup.sh) from your dotfiles, and add /sw to your $PATH manually so MacTeX wins.

  2. Call pdftex with the full path when you mean the MacTeX version: /usr/texbin/pdftex ...

Both are annoying. Option 1 is less annoying long-term.

More notes on our LaTeX page: https://charlesreid1.com/wiki/LaTeX

Tags:    latex    mac    tex    texmf    packages   

How to Subscribe to Infinite Mailing Lists

Posted in Reading

permalink

This is a quick hack, but a useful one.

Here's the hack:

  • Create a new and separate Gmail address, whose purpose is to be a "reading material" email address. The purpose of this email address is to sign up for mailing lists and reading material - that's it.

  • Once you have done that, log in to your primary email address. Find every mailing list you're subscribed to, and unsubscribe. This will give you a massive feeling of relief.

  • Sign up for the mailing lists you wish to keep on your reading list, but this time do it using the new mailing list email address.

  • This is key: on your phone, your laptop, any device, log out from your primary email address, and log in permanently to the new reading material email address instead. (This is a big security win - you're no longer permanently logged in to a sensitive personal email address just so you can read a monthly newsletter on your phone.)

This approach has several advantages:

  • Being permanently logged in to your primary email address on your computer or phone is a big security risk, since once a malicious actor has access to the device, they have access to your primary email, and through your primary email, the power to reset passwords for just about every service linked to that email address. (Yikes.)

  • Splitting high-impact duties from mundane duties (getting the newspaper versus the ability to reset the password for your bank account) is a good decision always. Now you can stay permanently logged in to the mailing list email address, and read about your favorite baseball team or cryo currency, without risking a massive security compromise or idientity theft because you were permanently logged in to your identity-attached primary email address.

  • Having a separate email address greatly reduces the anxiety around signing up for new mailing lists. Since every new mailing list email goes into one giant melting pot of reading material - a cross between a digital un-library and a well-organized email inbox with the opposite goal of Inbox Zero - there's no concern that signing up for a new mailing list is going to create a new and unwelcome stream of distractions in your primary email account. It goes into a reading room that can accumulate - if you so desire - centuries' worth of unread material. With a mailing list email address, you will feel none of the anxiety of having to read the material your un-library is accumulating, and you will gain all of the benefit of having a vast library that you can wander through in your free time.

  • (Hence, infinite mailing lists.)

Pro tips:

  • When you sign up for a new mailing list, it's good to create a filter for that mailing list as soon as it shows up in your reading inbox. The way my reading inbox is set up, I'm signed up for dozens of mailing lists, but only two or three emails actually arrive in the inbox each weekday (and one on the weekend).

  • By picking the most important mailing lists and having them filtered to always be delivered to the inbox, it helps cut through the noise of dozens of mailing list subscriptions.

Tags:    reading    mailing lists    productivity   

March 2022

How to Read Ulysses

July 2020

Applied Gitflow

September 2019

Mocking AWS in Unit Tests

May 2018

Current Projects

November 2017

A Hard(y) Math Problem