as a PDF

WHAT’S IN YOUR WALLET?!
LARA PUDWELL AND ERIC ROWLAND
Abstract. We use Markov chains and numerical linear algebra — and several
CPU hours — to determine the most likely set of coins in your wallet under
reasonable spending assumptions. We also compute a number of additional
statistics. In particular, the expected number of coins carried by a person in
the United States in our model is 10.
1. Introduction
While you probably associate the title of this paper with credit card commercials,
we suggest that it is actually an invitation to some pretty interesting mathematics.
Every day, when customers spend cash for purchases, they exchange coins. There
are a variety of ways a spender may determine which coins from their wallet to
give a cashier in a transaction, and of course a given spender may not use the
same algorithm every time. In this paper, however, we make some simplifying
assumptions so that we can provide an answer to the question “What set of coins
is most likely to be the contents of your wallet?”
Of course, the answer depends on where you live! A currency is a set of denominations. Primarily we’ll use the currency consisting of the common coins in the
United States, which are the quarter (25 cents), dime (10 cents), nickel (5 cents),
and penny (1 cent). However, we invite the reader to grab their passport and carry
out the computations for other currencies. Since we are interested in distributions
of coins, we will consider prices modulo 100 cents, in the range 0 to 99.
We’ll discuss how a spender determines which coins to use in a transaction
shortly. Let’s start with a simpler question. How does a cashier determine which
coins to give you as change when you overpay? If you are due 30 cents, a courteous
cashier will not give you 30 pennies. Generally the cashier minimizes the number of
coins to give you, which for 30 cents is achieved by a quarter and nickel. Therefore
let’s make the following assumptions about the world.
(1) The fractional parts of prices are distributed uniformly between 0 and 99
cents.
(2) Cashiers return change using the fewest possible coins.
Is there always a unique way to make change with the fewest possible coins? It
turns out that for every integer n ≥ 0 (not just 0 ≤ n ≤ 99) there is a unique
integer partition of n into parts of 25, 10, 5, and 1 that minimizes the number of
parts. And this is what the cashier gives you, assuming there are enough coins
of the correct denominations in the cash register to cover it. This is a reasonable
assumption since a cashier with only 3 quarters, 2 dimes, 1 nickel, and 4 pennies
can give change for any price that might arise.
Date: June 9, 2013.
1
2
Lara Pudwell and Eric Rowland
The cashier can quickly compute the minimal partition using the greedy algorithm. To construct a partition of n into parts d1 , d2 , . . . , dk using the greedy
algorithm, do the following. If n = 0, then use the empty partition {}. If n ≥ 1,
determine the largest di that is less than or equal to n, and add di to the partition;
then recursively construct a partition of n − di into parts d1 , d2 , . . . , dk . For example, if 37 cents is due, the cashier first takes a quarter from the register; then it
remains to make change for 37 − 25 = 12 cents, which can most closely be approximated (without going over) by a dime, and so on. The greedy algorithm partitions
37 into {25, 10, 1, 1}.1
We remark that for other currencies the greedy algorithm does not always produce partitions of integers into fewest parts. For example, if the only coins in
circulation were a 4-cent piece, a 3-cent piece, and a 1-cent piece, the greedy algorithm makes change for 6 cents as {4, 1, 1}, whereas {3, 3} uses fewer coins. In
Section 4.4 we’ll see a more natural example. In general it is not straightforward
to tell whether a given currency lends itself to optimal partitions under the greedy
algorithm. Indeed, there is substantial literature on the subject [1, 3, 4, 5, 7, 9]
and at least one published false “theorem” [6, 10]. Pearson [12] gave the first fast
(polynomial-time) algorithm for determining whether a given currency has this
property.
2. The coin keeper
We first consider the fate of the coin keeper. The coin keeper is the spender who
chooses to never spend coins. This happens for a variety of reasons. Sometimes
when you’re traveling internationally it’s easier to hand the cashier a big bill than
try to make exact change with foreign coins. Or maybe you don’t like making exact
change even with domestic coins, and at the end of each day you throw all your
coins into a jar. In either case, you will certainly collect a large number of coins.
What is the distribution?
One can easily compute the change you receive if you spend no coins in each
of the 100 possible transactions corresponding to prices from 0 to 99 cents. Since
we assume these prices appear with equal likelihood, to figure out the long-term
distribution of coins in the coin keeper’s collection, we need only tally the coins
of each denomination and note the ratios of quarters to dimes to nickels to pennies. A quick computer calculation shows that the coins received from these 100
transactions total 150 quarters, 80 dimes, 40 nickels, and 200 pennies. In other
words, a coin keeper’s stash contains 31.9% quarters, 17.0% dimes, 8.5% nickels,
and 42.6% pennies.
What’s in the country’s wallet? Interestingly enough, the coin keeper’s distribution looks radically different from that of coins actually manufactured by the
U.S. mint. In 2012, the U.S. government minted 568 million quarters, 1676 million
dimes, 1024 million nickels, and 6015 million pennies [16] — that’s 6.1% quarters,
18.1% dimes, 11.0% nickels, and 64.8% pennies.
Are there any currencies that result in a coin keeper’s jar where all denominations are equally distributed? A country using such a currency could mint all
denominations in equal numbers if its citizens were all coin keepers. Let’s require
1Maurer [10] interestingly observes that before the existence of electronic cash registers, cashiers
typically did not use the greedy algorithm but instead counted up from the purchase price to the
amount tendered — yet still usually gave change using the fewest coins.
What’s in YOUR wallet?!
3
that the currency contains a 1-cent coin, since a reasonable currency system has a
denomination for its unit. As the interested reader can check, it turns out that in
a currency with only 10-cent coins and 1-cent coins, there are an equal number of
each given as change. This fact is a special case of the following result.
Proposition 1. In a currency with only d-cent coins and 1-cent coins, the expected
ratio of d-cent coins to 1-cent coins in the coin keeper’s collection is
99
P
bi/dc
i=0
99
P
.
(i mod d)
i=0
Proof. Since the cashier returns change using the greedy algorithm, he or she first
gives as many d-cent coins as possible (namely bi/dc such coins when i cents in
change is due), and then the remainder (i mod d) is given in 1-cent coins.
If d divides 100 then the expression in Proposition 1 can be written
100 − d
,
d(d − 1)
which for d = 10 evaluates to 1. A computer search reveals that there are no
other currencies of 2, 3, or 4 denominations from {1, . . . , 99} that contain a 1-cent
piece and that yield all coins in the same proportions. Are there larger currencies
that do? For a general modulus (not necessarily 100), which currencies cause coin
keepers to have equal distributions of coins? We leave these as open questions, and
we move on to spenders who are not quite so lazy.
3. Markov chains
Spenders who don’t keep all their coins generally spend coins in such a way as
to not accumulate large quantities. In the remainder of the paper we will consider
a spending model that results in only finitely many possible wallet states. In this
model we can reasonably ask about the most likely state.
When a spender pays for his weekly groceries, the state of his wallet as he leaves
the store depends only on
(i) the state of his wallet when he entered the store,
(ii) the price of the groceries, and
(iii) the algorithm he uses to determine how to pay for a given purchase with a
given wallet state.
So what we have is a Markov chain.
A Markov chain is a system in which for all t ≥ 0 the probability of being in a
given state at time t depends only on the state of the system at time t − 1. Here
time is discrete, and at every time step a random event occurs to determine the
new state of the system. The main defining feature of a Markov chain is that the
probability of the system being in a given state does not depend on the system’s
history before time t−1. For us, the system is the spender’s wallet, and the random
event is the purchase price.
Let S = {s1 , s2 , . . . } be the set of possible states of the system. A Markov chain
with finitely many states has a |S| × |S| transition matrix M whose entry mij is
defined as follows. Let mij be the probability of transitioning to sj if the current
4
Lara Pudwell and Eric Rowland
state of the system is si . By assumption, mij is independent of the time at which
si occurs. The transition matrix contains all the information about the Markov
chain. Note that the sum of each row is 1.
As a small example, consider a currency with only 50-cent coins and 25-cent
coins, and suppose all prices end in 0, 25, 50, or 75 cents. Suppose also that if the
spender has sufficient change to pay for their purchase, then they do so using the
greedy algorithm. If the spender does not have sufficient change, they pay with
bills and receive change. The sets of coins obtained as change from transactions in
this model are {}, {25}, {50}, and {25, 50}. Therefore the possible wallet states are
s1 = {}, s2 = {25}, s3 = {50}, s4 = {25, 25}, s5 = {25, 50}, and s6 = {25, 25, 25}.
Further, if all 4 prices are equally likely, the transition matrix M is a 6 × 6 matrix
where all entries are either 14 or 0. For example, row 2 of M is 14 41 0 14 14 0
because there is a 14 chance of moving from s2 to each of s1 , s2 , s4 , and s5 , and no
chance of moving directly from s2 to s3 or s6 . The entire transition matrix is
1 1 1

0 14 0
4
4
4
 1 1 0 1 1 0
 41 41 1 4 41


0 4 0
4
4
4

M =
1 1 0 1 0 1 .
 41 41 1 4 1 4 

0 4 0
4
4
4
1
1
0 14 0 14
4
4
The reason for putting the transition probabilities mij in a matrix is that the
multiplication of a vector by M carries meaning. Suppose that you don’t know
the state of your friend’s wallet, but (for some strange reason)
you do know the
probability vi of the wallet being in state si for each i. Let v = v1 v2 · · · v|S|
be a vector whose entries are the probabilities vi . In particular, the entries of v are
nonnegative and sum to 1. Then vM is a vector whose ith entry is the probability
of the wallet being in state si after your friend makes her next cash purchase.
(Convince yourself!)
After one step, we can think of vM as the new probability distribution and ask
what happens after a second transaction. Since the probability distribution of the
wallet states after one step is vM , the probability distribution after two steps is
(vM )M , or in other words vM 2 .
The long-term behavior of your friend’s wallet is therefore given by vM n for
large n. If the limit p = limn→∞ vM n exists, then there is a very clean answer
to the question “What’s most likely to be in your friend’s wallet?”, since the ith
entry pi of p is the long-term probability that the wallet is in state si . Moreover,
if the limit is actually independent of the initial distribution v, then p is not just
the long-term distribution for your friend’s wallet; it’s the long-term distribution
for anyone’s wallet.
Supposing for the moment that p exists, how can we compute it? Well, the
limiting probability distribution does not change under multiplication by M (because otherwise it’s not the limiting probability distribution), so pM = p. In other
words, p is a left eigenvector of M with eigenvalue 1. There may be many such
eigenvectors, but we know additionally that p1 + p2 + · · · + p|S| = 1, which may be
enough to uniquely determine the entries
of p. 5
3
7
1
In our toy example, we obtain p = 41 14 32
32
32
32 , which indicates
there is a 25% chance of having an empty wallet, and a 25% chance of having a
What’s in YOUR wallet?!
5
wallet with just one quarter. On the other hand, the least likely wallet state is
s6 = {25, 25, 25}, and this state occurs with probability 3.125%.
Theorem 2 below guarantees the existence and uniqueness of p. But we need
two conditions on the Markov chain. The first is irreducibility. A Markov chain is
irreducible if for each si and sj there is some n ≥ 0 such that the probability of
transitioning from si to sj in n steps is nonzero. That is, each state is reachable
from each other state, so the state space can’t be broken up into two nonempty
sets that don’t interact with each other in the long term.
The second condition is aperiodicity. A state si is periodic if there is some integer
k ≥ 2 (the period ) such that if there is a nonzero probability of being in state si
both at time t1 and time t2 then k divides t2 − t1 . A Markov chain is aperiodic
if none of its states are periodic. For example, the Markov chain whose transition
matrix is
0 1
M=
1 0
is not aperiodic, since both states are periodic with period 2. A periodic state can
prevent limn→∞ vM n from existing.
Theorem 2. Let M be the transition matrix of an irreducible, aperiodic Markov
chain. Then:
•
•
•
•
The limit L := limn→∞ M n exists and has nonnegative entries.
All rows of L are identical and equal to a vector p.
p is the unique vector satisfying pM = p whose entries sum to 1.
For any initial distribution v, we have limn→∞ vM n = p.
This formulation of Theorem 2 comes from Sullivan [15, Section 10.2]. For a
proof, see Norris [11, Theorems 1.7.2 and 1.8.3].
4. The big spender
This brings us to the question of how a spender spends coins. Unlike the cashier,
the spender has a limited supply of coins. When the supply is limited, the greedy
algorithm does not always make exact change. For example, if we’re trying to come
up with 30 cents and our wallet state is {25, 10, 10, 10} then the greedy algorithm
fails to identify {10, 10, 10}.
Moreover, the spender will not always be able to make exact change. Since our
spender does not want to accumulate arbitrarily many coins (unlike in Section 2),
let’s assume that if the spender has enough coins to cover the cost, they spend coins
but overpay as little as possible. For example, if the wallet state is {25, 10, 5, 1, 1}
and the price is 13 cents, then the spender spends {10, 5}.
How does a spender identify a subset of coins whose total is the smallest total
that is greater than or equal to the purchase price? Well, one way is to examine all
subsets of coins in the wallet and compute the total of each. This naive algorithm
is not particularly fast, but it turns out to be fast enough for our purposes.
Now, there may be multiple subsets of coins in the wallet with the same minimal
total. For example, if the wallet state is {10, 5, 5, 5} and the price is 15 cents, there
are two ways to make change. Using the greedy algorithm as inspiration, let us
assume the spender breaks ties by favoring bigger coins and spends {10, 5} rather
than {5, 5, 5}.
6
Lara Pudwell and Eric Rowland
In addition to the two assumptions in Section 1, our assumptions are therefore
the following.
(3) If a spender does not have sufficient change to pay for (the fractional part
of) their purchase, the spender spends no coins and receives change from
the cashier.
(4) If a spender has sufficient change, he or she makes their purchase by overpaying as little as possible and receives change if necessary.
(5) If there are multiple ways to overpay as little as possible, the spender favors
{a1 , a2 , . . . , am } over {b1 , b2 , . . . , bn }, where a1 ≥ a2 ≥ · · · ≥ am and b1 ≥
b2 ≥ · · · ≥ bn , if a1 = b1 , a2 = b2 , . . . , ai = bi and ai > bi for some i.
We refer to a spender who follows these rules as a big spender. The following
lemma implies that there are only finitely many states for a big spender’s wallet.
Lemma 3. Suppose a spender adheres to assumptions (3) and (4). If the spender
has at most 99 cents in his or her wallet before a transaction, then they have at
most 99 cents in their wallet after the transaction.
Proof. Let 0 ≤ p ≤ 99 be (the fractional part of) the price, and let w be the total
value of coins in the spender’s wallet.
If p ≤ w, by (4), the spender will pay at least p cents, receive change if necessary,
and end with w − p cents after the transaction. Since w ≤ 99 and p ≥ 0, we know
that w − p ≤ 99 as well.
If p > w, since w is not enough to pay p cents, by (3) the spender will only pay
with bills, and will receive 100−p in change, for a total of w+100−p = 100−(p−w)
after the transaction. Since p > w, we know that p−w > 0, so 100−(p−w) ≤ 99. If a big spender has more than 99 cents in his or her wallet (because they did
well at a slot machine), then they will spend coins until they have less than 99
cents, and then Lemma 3 applies. Thus any wallet state with more than 99 cents
is only transient and will have a long-term probability of 0. Since there are finitely
many ways to carry around 99 or fewer cents, the state space of the big spender’s
wallet is finite.
The next lemma shows that the Markov chain for the big spender is irreducible.
Lemma 4. Let s1 and s2 be two wallet states with at most 99 cents in coins each.
A spender adhering to assumptions (1)–(4) can transition from state s1 to state s2
via a finite sequence of transactions.
Proof. We prove the lemma for a general currency with denominations d1 > d2 >
· · · > dk . We will exhibit a finite sequence of transactions that takes s1 to the
empty wallet and another sequence that takes the empty wallet to s2 . Let ai be
the number of coins of denomination di in s2 for each 1 ≤ i ≤ k.
To get from s1 to the empty wallet, note that if the price is the total value of
s1 , then by (4) he or she will spend all coins and have an empty wallet after one
transaction. Since the value of s1 is at most 99 by assumption, this is a valid price
which occurs with nonzero probability by (1).
Now, to get from the empty wallet to s2 , notice that if the price is 100 − d`
Pk
and i=1 ai · di < 100 − d` , then by (3) the spender pays nothing and by (2) they
get d` in change, given greedily as a single coin. Consider a1 charges of 100 − d1
cents, followed by a2 charges of 100 − d2 cents, . . . , followed by ak charges of
100 − dk cents. At any point in time when 100 − d` (1 ≤ ` ≤ k) is charged, the
What’s in YOUR wallet?!
7
P`−1
spender has i=1 ai di + (a` − b)d` cents in his or her wallet for some b ≥ 1. Since
Pk
P`−1
i=1 ai · di ≤ 99, we know that
i=1 ai di + (a` − b)d` ≤ 99 − d` < 100 − d` , so
the spender receives a d` -cent coin as change. Thus this sequence of transactions
yields wallet state s2 .
To apply Theorem 2, it remains to check that the Markov chain for a big spender
is aperiodic. It is easy to see that no state si is periodic, since if the wallet is in
state si then the transaction with price 0 causes the wallet to transition to si .
Therefore the big spender’s wallet is an irreducible, aperiodic Markov chain. In
the remainder of this section, we use the finite-state Markov chain framework under
assumptions (1)–(5) to analyze the distribution of wallet states in four different
currency scenarios: the pennyless purchaser, the quarter hoarder, the full fourdenomination U.S. currency, and a fictional currency. The lists of wallet states
and the explicit transition matrices can be downloaded from the authors’ web sites,
along with a Mathematica notebook containing our computations.
4.1. The pennyless purchaser. A penniless purchaser is a spender who has no
money. Consequently, their long-term wallet behavior is not too difficult to analyze.
On the other hand, a pennyless purchaser is a spender who never carries pennies
but does carry other coins. Pennyless purchasers arise in at least two different
ways. Some governments prefer not to deal with pennies. Canada, for example,
has stopped minting pennies as of May 4, 2012, so transactions in Canada will
eventually not involve pennies. On the other hand, some people prefer not to
deal with pennies and drop any they receive into the give-a-penny/take-a-penny
tray. Therefore prices for the pennyless purchaser are effectively rounded up to
the nearest multiple of 5 cents, and it suffices to consider 20 prices rather than
100. Moreover, these 20 prices occur with equal frequency as a consequence of
assumption (1).
The possible states for the pennyless purchaser’s wallet are the states consisting
of quarters, dimes, and nickels totaling at most 99 cents. Each state contains at
most 3 quarters, 9 dimes, and 19 nickels, and a quick computer filter shows that of
these 4 × 10 × 20 = 800 potential states only 213 have value at most 99 cents.
To construct the transition matrix for the pennyless purchaser Markov chain,
we simulate each possible transaction and count, for each pair of states si , sj , the
prices that take the wallet from si to sj . There are 213 × 20 = 4260 transactions
to consider, and the resulting matrix has dimensions 213 × 213. By Lemma 4, the
Markov chain is irreducible, and we also know that it is aperiodic, so Theorem 2
applies and the limiting distribution p exists. The matrix M is small enough that
if we consider the equation pM = p as a system of equations in the 213 components
of p, along with the normalization equation p1 + p2 + · · · + p213 = 1, it can be solved
on any modern computer using Gaussian elimination with exact rational number
arithmetic.
There is a tie for the most likely state! The empty wallet {} and the one1
. While a 5% chance of
nickel wallet {5} each have a limiting probability of 20
occurring may not seem large, note this is over 10 times as likely as in the uniform
1
distribution where all states have equal likelihood 213
≈ .00469. The ten most
likely and least likely states, along with their long-term probabilities, are given in
the left half of Table 1. None of the other 211 states occur with “nice” frequencies;
the denominators all have at least 236 digits. At the other end of the spectrum is
8
Lara Pudwell and Eric Rowland
Wallet state
{}
{5}
{10, 5}
{25, 10, 5}
{25, 5}
{10, 5, 5}
{25, 25, 10, 5}
{5, 5}
{10}
{25, 10,
.. 5, 5}
.
14 nickels
2 dimes and 15 nickels
1 dime and 15 nickels
15 nickels
1 dime and 16 nickels
16 nickels
1 dime and 17 nickels
17 nickels
18 nickels
19 nickels
ppp
.05000
.05000
.03916
.03093
.02847
.02731
.02625
.02536
.02463
.02417
..
.
1.29 × 10−11
3.37 × 10−12
2.28 × 10−12
9.90 × 10−13
1.76 × 10−13
6.23 × 10−14
1.27 × 10−14
3.96 × 10−15
2.09 × 10−16
1.10 × 10−17
Wallet state
{1, 1, 1, 1}
{1, 1, 1}
{1, 1}
5 pennies
{1}
6 pennies
{}
7 pennies
8 pennies
9 pennies
10 pennies
{10, 5, 1, 1, 1, 1, 1, 1, 1, 1}
{10, 5, 1, 1, 1, 1, 1, 1, 1}
11 pennies
{10, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1}
{10, 5, 1, 1, 1, 1, 1, 1}
{10, 5, 1, 1, 1, 1, 1}
12 pennies
{10, 5, 1, 1, 1, 1}
{10, 1, 1, 1, 1, 1, 1}
{10, 1, 1, 1, 1, 1, 1, 1}
pqh
.01164
.01129
.01095
.01084
.01062
.01039
.01030
.00984
.00919
.00844
.00713
.00651
.00642
.00638
.00637
.00614
.00569
.00564
.00549
.00523
.00522
Table 1. Left: The 10 most and least likely wallet states for the
pennyless purchaser. Right: The 21 most likely wallet states
for the quarter hoarder.
the case of amassing 19 nickels and no other coins, which happens with probability
≈ 10−17 . If you ever have 19 nickels in your wallet then you’ve done something
wrong!
4.2. The quarter hoarder. The quarter hoarder is a spending strategy utilized
by college students and apartment dwellers who save all their quarters for laundry.
All quarters they receive as change are immediately thrown into their laundry fund,
so the quarter hoarder’s wallet contains only dimes, nickels, and pennies.
Of the 10 × 20 × 100 = 20000 potential wallet states containing up to 9 dimes,
19 nickels, and 99 pennies, there are 4125 states for which the total is less than 100
cents. Constructing the transition matrix requires simulating 4125 × 100 = 412500
transactions, and this is the time-consuming part. The authors’ implementation
took 4 hours to run these transactions on a 2.6 GHz laptop. The transition matrix
has dimensions 4125 × 4125, which is significantly larger than the matrix for the
pennyless purchaser.
For matrices of this size, Gaussian elimination is slow. If we don’t care about the
entries of the limiting probability vector p as exact rational numbers but are happy
with approximations, it’s much faster to use numerical methods. Arnoldi iteration
is an efficient method for approximating the largest eigenvalues and associated
eigenvectors of a matrix, without computing them all. The details are beyond the
scope of this paper, but the interested reader should take a look at any textbook on
What’s in YOUR wallet?!
9
numerical linear algebra. It follows from the Perron–Frobenius theorem in linear
algebra that the dominant eigenvalue (the very largest eigenvalue) of the transition
matrix for any Markov chain is 1, so this is the eigenvalue we are interested in; its
associated dominant eigenvector is indeed p.
Fortunately, an implementation of Arnoldi iteration due to Lehoucq and Sorensen [8]
is available in the package ARPACK [13], which is free for anyone to download and
use. This package is also included in Mathematica [17], so to compute the dominant
eigenvector of a matrix one can simply evaluate
Eigenvectors[N[Transpose[matrix]], 1]
in Mathematica. The symbol N converts rational entries in the matrix into floatingpoint numbers, and Transpose ensures that we get a left (not right) eigenvector.
ARPACK is quite fast — the computation for the quarter hoarder takes less than
a second. And one finds that the most likely wallet state for the quarter hoarder is
{1, 1, 1, 1}, which occurs with probability .01164. The right half of Table 1 shows the
most likely wallet states and their probabilities. Because we have used numerical
methods, the results are only accurate to a certain precision; hence the probabilities
of very unlikely states may be smaller than this precision and therefore unreliable
to rank the least likely states by.
4.3. The whole shebang. Finally we come to the most common spender — the
spender who uses all available denominations. Of the 4 × 10 × 20 × 100 = 80000
wallet states containing up to 3 quarters, 9 dimes, 19 nickels, and 99 pennies, 6720 of
them have a value less than 100 cents. Simulating 6720×100 = 672000 transactions
to compute the transition matrix took our implementation 1 CPU day. But once
this is done, numerical methods again quickly compute the dominant eigenvector
p. The 25 most likely wallet states are shown in the left half of Table 2. There are
five most likely states, each with a probability of .01000; they are the empty wallet
{} and the states consisting of 1, 2, 3, or 4 pennies. Therefore 5% of the time the
big spender’s wallet is in one of these states.
From p we can compute all sorts of interesting and uninteresting statistics. For
example, the expected number of coins in your wallet, which is arguably more
relevant than which particular states are most likely, is 10.04. The probability
that your wallet contains at least one nickel is .58085, whereas the probability of
having at least one penny is .95975. The probability of having only pennies (and a
nonempty wallet) is .08430. The probability of having an empty wallet is .01000.
And the probability of being able to pay any price with exact change is .00831.
The expected number of quarters in your wallet is 1.06; the expected numbers of
dimes, nickels, and pennies are 1.15, .91, and 6.92. From this we can also compute
the distribution of coins in circulation. We’ll need to assume that all coin holders
are big spenders; of course this is not actually the case, since cash registers have too
many coins to be big spenders. But if all coin holders were big spenders, then the
distribution of circulating coins would be 10.5% quarters, 11.5% dimes, 9.1% nickels,
and 68.9% pennies. Compare this to the distribution of U.S. minted coins in 2012
— 6.1% quarters, 18.1% dimes, 11.0% nickels, and 64.8% pennies. Relative to the
coin keeper model of Section 2, the big spender distribution comes several times
closer (as points in four-dimensional space) to the U.S. mint distribution.
4.4. A fictional currency. We conclude with a currency that no one actually
uses. Under assumptions (1) and (2), Shallit [14] asked how to choose a currency
10
Lara Pudwell and Eric Rowland
Wallet state
0–4 pennies
5 pennies
6 pennies
7 pennies
8 pennies
{5, 1, 1, 1, 1}
{25, 1, 1, 1, 1}
{10, 1, 1, 1, 1}
9 pennies
{25, 1, 1, 1}
{5, 1, 1, 1}
{10, 5, 1, 1, 1, 1}
{25, 1, 1}
{10, 1, 1, 1}
{10, 1, 1, 1, 1, 1}
{25, 1}
{10, 1, 1, 1, 1, 1, 1}
{25}
{10, 5, 1, 1, 1, 1, 1, 1}
{25, 1, 1, 1, 1, 1}
{10, 5, 1, 1, 1, 1, 1}
pshebang
.05000
.00813
.00732
.00644
.00551
.00543
.00475
.00467
.00456
.00453
.00448
.00439
.00429
.00420
.00414
.00405
.00391
.00379
.00377
.00376
.00375
Wallet state
0–4 pennies
{5, 1, 1, 1, 1}
{5, 5, 1, 1, 1, 1}
{5, 1, 1, 1}
{5, 5, 1, 1, 1}
{5, 1, 1}
{1, 1, 1, 1, 1}
{5, 5, 1, 1, 1, 1, 1}
{5, 1, 1, 1, 1, 1}
{5, 5, 1, 1, 1, 1, 1, 1}
{5, 5, 1, 1}
{5, 1}
{1, 1, 1, 1, 1, 1}
{5, 1, 1, 1, 1, 1, 1}
{18, 1, 1, 1, 1}
{5, 5, 1, 1, 1, 1, 1, 1, 1}
{18, 1, 1, 1}
{5, 5, 5, 1, 1}
{18, 1}
{18, 1, 1}
{5, 5, 1}
pShallit
.05000
.00789
.00721
.00710
.00625
.00618
.00594
.00575
.00541
.00527
.00522
.00515
.00484
.00476
.00475
.00461
.00449
.00429
.00429
.00420
.00414
Table 2. The 25 most likely wallet states in the whole shebang
and in the Shallit currency.
so that cashiers return the fewest coins per transaction on average. For a currency
d1 > d2 > d3 > d4 with four denominations, he computed that the minimum
possible value for the average number of coins per transaction is 389/100, and this
minimum is attainable with a 25-cent piece, 18-cent piece, 5-cent piece, and 1cent piece. So as our final model, we consider a fictional country that has adopted
Shallit’s suggestion of replacing the 10-cent piece with an 18-cent piece. The number
of wallet states totaling at most 99 cents is 4238, which is just slightly more than
the possible states for the quarter hoarder.
There are two surprises about this currency. The first is that the greedy algorithm doesn’t always make change using the fewest possible coins! For example, to
make 28 cents the greedy algorithm gives {25, 1, 1, 1}, but you can do better with
{18, 5, 5}.
The second surprise is that there is not always a unique way to make change
using the fewest possible coins! For example, 77 cents can be given in five coins
as {25, 25, 25, 1, 1} or {18, 18, 18, 18, 5}. The prices 82 and 95 also have multiple
minimal representations. (Bryant, Hamblin, and Jones [2] give a characterization
of currencies d1 > d2 > d3 that avoid this feature, but for more than three denominations no simple characterization is known.) According to assumption (5),
the big spender breaks ties between minimal representations of 77, 82, and 95 by
favoring bigger coins. For example, the big spender spends {25, 25, 25, 1, 1} rather
than {18, 18, 18, 18, 5} if both are possible.
What’s in YOUR wallet?!
11
The cashier doesn’t care about getting rid of big coins, however. So to make
things interesting, let’s replace assumption (2) with the following.
(20 ) Cashiers return change using the fewest possible coins; when there are two
ways to make change with fewest coins, the cashier uses each half the time.
For example, a cashier makes change for 77 cents as {25, 25, 25, 1, 1} with probability
1/2 and as {18, 18, 18, 18, 5} with probability 1/2. Consequently, the transition
matrix has some entries that are 1/200.
Table 2 shows the most likely states. The likelihood of having at least one 18-cent
piece in your wallet at a given time is .56424, as opposed to .63378 for having at
least one dime in your wallet in the U.S. currency. The expected number of coins in
your wallet is 8.63, so in addition to reducing the number of coins per transaction,
the Shallit currency also reduces the number of coins in your wallet.
5. Conclusion
In this paper, we have taken the question “What’s in your wallet?” quite literally
and considered two spending models — the coin keeper and the big spender. In
each model we were able to compute the long-term behavior of wallets in various
currencies. For the big spender we ran into big Markov chains, and computing the
limiting probability vector required numerical linear algebra.
The framework we have outlined is of course applicable to other currencies. In
fact, it would be interesting to know in which country of the world is a big spender
expected to carry the fewest coins. Or, which currency d1 > d2 > d3 > d4 of four
denominations minimizes the average number of coins in your wallet?
One embarrassing feature is that while Arnoldi iteration allows us to quickly
compute the dominant eigenvector of a transition matrix, the computation of the
matrix itself is quite time-consuming. We are using the naive algorithm, which
looks at all subsets of a wallet to determine which subset to spend. What is a
faster algorithm for computing the big spender’s behavior?
Our framework is also applicable to other spending models. And indeed there
are good reasons to vary some of our assumptions. For example, assumption (3)
isn’t universally true. If you are charged 76 cents and your wallet is {1} then you
might spend the 1-cent coin to receive 25 cents in change rather than 24 cents.
What is a good spending algorithm that captures this?
Assumption (5) is not universally true either. Given the choice between spending
a quarter or five nickels, the big spender spends the quarter. While the big spender
minimizes the number of coins he or she spends, it is also reasonable to suppose
that a spender would maximize the coins they spend so as to minimize the number
of coins in their wallet. Of course, the best way to minimize the number of coins in
your wallet is to curtly throw all your coins at the cashier and make them give you
change (greedily). But since we are strictly interested in civil models of spending,
we could consider a heavy spender who maximizes the number of coins spent from
his or her wallet in a given transaction according to the following modification of
assumption (5).
(50 ) If there are multiple ways to overpay as little as possible, the spender favors
{a1 , a2 , . . . , am } over {b1 , b2 , . . . , bn } if m > n.
12
Lara Pudwell and Eric Rowland
When given the choice, a heavy spender favors {5, 5, 5} over {10, 5}. Do assumptions (3), (4), and (50 ) completely determine the behavior of a heavy spender? If
so, does the heavy spender have a lighter wallet on average than the big spender?
Of course, the million dollar question is whether real people actually follow any
of these spending models. Perhaps there are experimental psychologists who are
willing to take this up.
References
[1] Anna Adamaszek and Michal Adamaszek, Combinatorics of the change-making problem,
European Journal of Combinatorics 31 (2010) 47–63.
[2] Lance Bryant, James Hamblin, and Lenny Jones, A variation on the money-changing problem,
The American Mathematical Monthly 119 (2012) 406–414.
[3] Xuan Cai, Canonical coin systems for change-making problems, http://arxiv.org/abs/
0809.0400.
[4] Lena Chang and James F. Korsh, Canonical coin changing and greedy solutions, Journal of
the Association for Computing Machinery 23 (1976) 418–422.
[5] S. K. Chang and A. Gill, Algorithmic solution of the change-making problem, Journal of the
Association for Computing Machinery 17 (1970) 113–122.
[6] John Dewey Jones, Orderly currencies, The American Mathematical Monthly 101 (1994)
36–38.
[7] Dexter Kozen and Shmuel Zaks, Optimal bounds for the change-making problem, Theoretical
Computer Science 123 (1994) 377–388.
[8] Richard B. Lehoucq and Danny C. Sorensen, Deflation techniques for an implicitly restarted
Arnoldi iteration, SIAM Journal on Matrix Analysis and Applications 17 (1996) 789–821.
[9] M. J. Magazine, G. L. Nemhauser, and L. E. Trotter, Jr., When the greedy solution solves a
class of knapsack problems, Operations Research 23 (1975) 207–217.
[10] Stephen B. Maurer, Disorderly currencies, The American Mathematical Monthly 101 (1994)
419.
[11] J. R. Norris, Markov Chains, Cambridge University Press (1998).
[12] David Pearson, A polynomial-time algorithm for the change-making problem, Operations
Research Letters 33 (2005) 231–234.
[13] Rice University, ARPACK, http://www.caam.rice.edu/software/ARPACK/.
[14] Jeffrey Shallit, What this country needs is an 18¢ piece, The Mathematical Intelligencer 25
(2003) 20–23.
[15] Michael Sullivan, Finite Mathematics: An Applied Approach 11th edition, John Wiley &
Sons (2011).
[16] United States Mint, Production and sales figures, http://www.usmint.gov/about_the_mint/
?action=coin_production.
[17] Wolfram Research, Some notes on internal implementation, http://reference.wolfram.com/
mathematica/tutorial/SomeNotesOnInternalImplementation.html#15781.
Department of Mathematics and Computer Science, Valparaiso University, Valparaiso,
Indiana 46383, USA
Laboratoire de combinatoire et d’informatique mathématique, Université du Québec
à Montréal, Montréal, QC H2X 3Y7, Canada