Whats in YOUR wallet?
We use Markov chains and numerical linear algebra -- and several CPU hours -- to determine the expected number of coins in a person's possession under certain conditions. We identify the spending strategy that results in the minimum possible expected…
Authors: Lara Pudwell, Eric Rowl
WHA T’S IN YOUR W ALLET? LARA PUDWELL AND ERIC R OW LAND While you probably asso ciate the title of this paper with credit card commercials, we suggest it is actually an invitation to some pre tty interesting mathematics. Every day , when customers sp end cash for purchases, they e xc hange co ins. There are a v ariet y of wa ys a sp ender ma y determine whic h coins from their w allet to give a cashier in a transactio n, and of course a given sp ender ma y not use the same algor ithm every time. In this pape r , howev er, w e make some simplifying assumptions so that w e can provide an answer to the question ‘What is the exp ected nu mber of coins in your w allet?’. Of cour s e, the answer d ep ends on where you live! A curr ency is a s et of de- nominations. W e ’ll fo cus on th e curre ncy consisting of the common co ins in the United States, which ar e the quarter (25 cents), dime (1 0 ce nts), nick el (5 cents), and p enn y (1 cent) . How ev er, we in vite you to grab your passp ort and carr y out the computatio ns for o ther currencies. Since we are interested in distributio ns o f coins, we will consider prices modulo 100 cen ts, in the range 0 to 99. The conten ts of your wallet lar g ely depend on how you choose which coins to use in a t ransa ction. W e’ll address this s ho rtly , but let’s star t with a simpler question. How does a cashier determine which coins to give you as change when you ov erpay? If you ar e due 30 cen ts, a courteous cashier will not give y ou 30 pe nnies . Generally the cashier minimizes the n umber of coins to give you, which for 30 cents is achiev ed by a qua r ter and nic kel. Therefo r e let’s make the fo llo wing assumptions. (1) The fractiona l par ts of prices are distr ibuted uniformly b etw een 0 a nd 99 cents. (2) Cashiers return change using the few est poss ible coins. Is there always a unique wa y to ma ke c hange with the few est p ossible coins? It turns out that for every integer n ≥ 0 (no t just 0 ≤ n ≤ 99) there is a uniq ue int eger pa rtition of n into par ts 25, 10, 5, and 1 that minimizes the n umber of parts. And this is what the cas hie r gives you, assuming there are eno ugh coins of the correct denominations in the ca sh r egister to cover it, which is a reasonable assumption since a cas hier with only 3 quar ters, 2 dimes, 1 nickel, and 4 p ennies can give change for any pr ice that migh t arise. The cashier can quickly compute the minimal pa rtition of an in teger n in to parts d 1 , d 2 , . . . , d k using the gr e e dy algorithm as follows. T o co nstruct a partition of n = 0 , use the empt y partition {} . T o construc t a partition of n ≥ 1, determine the larg est d i that is le s s than or equa l to n , and add d i to the pa rtition; then recursively co nstruct a partition of n − d i int o parts d 1 , d 2 , . . . , d k . F or example, if 37 cents is due, the cashier fir st takes a qua rter from the re g ister; then it remains to ma ke change for 3 7 − 25 = 12 cents, which can most closely b e a ppro ximated Date : May 24, 2015. 1 2 LARA P UD WELL AND ERIC RO WLAND (without going ov er) b y a dime, and so o n. The greedy algor ithm partitions 3 7 into { 25 , 10 , 1 , 1 } . 1 W e r emark that for o ther curre nc ie s the greedy a lgorithm do es not necess arily pro duce pa rtitions of integers int o fewest parts. F or example, if the only coins in circulation were a 4-cent piece, a 3 -cen t piece, and a 1 -cen t piec e, the greedy al- gorithm makes change for 6 cents as { 4 , 1 , 1 } , wherea s { 3 , 3 } uses fewer coins. In general it is not straig h tforward to tell whether a given currency lends itself to min- imal par titions under the g reedy algor ithm. Indeed, there is subs ta n tial litera ture on the s ub ject [1, 3, 4, 5, 7, 9] a nd a t leas t one published false “theor e m” [6, 10]. Pearson [1 1] gave the first p olynomial-time algorithm for determining whether a given curr ency has this prope rt y . As for sp ending coins, the simples t wa y to sp end coins is to not spend them at all. A c oin ke ep er is a sp ender who never sp ends coins. Sometimes when you’re trav eling in ternationa lly it’s easier to hand the cashier a big bill than try to make change with for eign coins . Or mayb e you don’t like making c hange ev en with domestic co ins, and at the end o f each da y you throw all your coins into a jar. In either case, you will co llect a large n um b er of coins. What is the distribution? It is eas y to compute the change you r eceiv e if you sp end no coins in each of the 1 00 p ossible transactions cor respo nding to prices from 0 to 9 9 cents. Since we assume these prices a ppear with equal lik eliho o d, to figure out the long -term distribution of co ins in a c o in keeper’s co lle ction, we need o nly tally the c oins of each denomination. A quic k computer ca lculation shows that the co ins r eceiv ed from these 100 tra nsactions total 15 0 quarters, 8 0 dimes, 40 nick els, and 200 pe n- nies. In other words, a c oin keepe r ’s stash contains 31.9% quarters, 17.0% dimes, 8.5% nick els, and 42.6 % p ennies. What’s in the country’s wallet? The coin keeper’s distribution lo oks quite differ- ent from that of coins ac tua lly manufactured by the U.S. min t. In 2 014, the U.S. gov ernment minted 158 0 million quarters, 2 302 million dimes, 1206 million nic kels, and 8146 million pennies [14] — that’s 11.9% quarters, 17.4% dimes, 9.1% nic kels, and 61.6% pennies. F ortunately , mo s t of us do not b ehav e a s coin keepe r s. So let us mov e on to sp enders who are not quite so lazy . Marko v chains When you pay for your weekly gro ceries , the state of your wallet as you leave the store depends only on (i) the state of your w allet when you entered the store, (ii) the price of the gr ocer ies, a nd (iii) the algorithm you use to determine ho w to pay for a given purchase with a given w allet state. So what w e hav e is a Marko v chain . A Ma rko v c hain is a system in whic h fo r all t ≥ 1 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 dis c rete, a nd at every time s tep a ra ndom event o ccurs to deter mine the new state of the system. The main defining feature of a Markov c hain is that the 1 Maurer [10] inte restingly observ es that b efore the existence of electronic cash registers, cashiers t ypically did not use the greedy algorithm but instead counted up from the purc hase pr ice to the amoun t tendered — yet stil l usually gav e c hange usi ng the fewest coins. WHA T’S IN YOUR W ALLET? 3 probability o f the system b eing in a given state do es no t de p end on the sys tem’s history b efore time t − 1 . F or us, the sys tem is the sp ender’s wallet, and the rando m even t is the purchase price. Let S = { s 1 , s 2 , . . . } be the set of po ssible states o f your wallet. A Marko v chain with finitely ma n y states has a | S | × | S | tr ansition matrix M whos e entry m ij is the probability of transitioning to s j if the current sta te of the system is s i . By ass umption, m ij is independent o f the time at which s i o ccurs. If v = v 1 , v 2 , . . . , v | S | is a vector whose ent ry v i is the probability o f your wallet being in state s i initially , then v M is a vector whose i th entry is the probability of the wallet b eing in state s i after o ne step. The long-ter m behavior of your wallet is ther efore given by v M n for larg e n . If the limit p = lim n →∞ v M n exists, then there is a clean answer to a question s uc h as ‘What is the exp ected num ber o f coins in your w allet?’, since the i th entry p i of p is the long-term probability that your wallet is in state s i . Moreover, if the limit is indep endent of the initial distribution v , then p is not just the long- term distribution for your wallet; it’s the long-term distribution for any wallet using the same sp ending strateg y . Suppo sing for the moment that p exists, how can we co mpute it? The limiting probability distr ibution do es not change under m ultiplication b y M (beca use oth- erwise it’s not the limiting probability distribution), so pM = p . In other words, p is a left e ig en vector of M with eigenv alue 1. There may b e many such eigenvec- tors, but we know additionally that p 1 + p 2 + · · · + p | S | = 1 , which may b e eno ugh information to uniquely determine the entries of p . It turns out that, under re a sonable sp ending assumptions, the Perron–F r obenius theorem guarantees the existence and uniq ue nes s o f p . W e need tw o co nditions on the Marko v chain — irreducibility and ap erio dicit y . A Markov chain is irr e ducible if for a n y tw o states s i and s j there is some integer n such that the pr obabilit y of transitioning from s i to s j in n steps is no nz e ro. That is, each state is reachable from ea c h other sta te, so the state space can’t b e broken up into tw o nonempty sets that don’t interact with each o ther in the lo ng term. F or each Mar k ov chain we consider, ir reducibilit y follows fro m assumptions (1)–(2) ab ov e and details of the particular sp ending s tr ategy (for example, assumptions (3)–(4) b elow). The other condition is ape r iodicity . A Markov chain is p erio dic (i.e., no t ap eri- o dic) if there is some s tate s i such that a n y tra nsition fr om s i to itself o ccurs in a m ultiple of k > 1 steps. If a wallet is in s tate s i , then the tra nsaction with price 0 causes the wallet to tra nsition to s i , so wallet Markov chains a re ap erio dic. There- fore the Perron–F r obenius theo rem implies that p exists a nd that p is the dominant left eigenv ector of the matr ix M , co r resp onding to the e ig en v alue 1. F rom p we can compute all so rts of statistics. F or ex ample, the exp ected num b er o f coins in the wallet is | S | X i =1 p i | s i | . The exp ected total v alue o f the wallet, in cents, is | S | X i =1 p i σ ( s i ) , where σ ( s i ) is the s um of the e lemen ts in s i . 4 LARA P UD WELL AND ERIC RO WLAND Spending stra tegies Now that we understand the mechanics of Mar kov chains, w e can use them to study v ar ious mo dels of a sp ender’s b ehavior. Unlike the cashier, the sp ender has a limited supply o f coins . When the supply is limited, the g reedy algor ithm do es not alwa ys make exa c t change. F or example, if you’re trying to come up with 30 cents and your wallet state is { 25 , 10 , 10 , 10 } then the gr e e dy algor ithm fa ils to identify { 10 , 10 , 10 } . Moreov er, the sp ender will not alwa ys be able to make exact change. Since our sp ender do es not w ant to accumulate arbitrarily many coins (unlike the coin keeper), let’s fir st consider the minimalist sp ender , who sp ends coins so as to min- imize the num b er o f coins in their wallet after each trans action. The m i nimalist sp ender. Of co urse, one wa y to b e a minimalis t sp ender is to curtly thr o w a ll your coins at the cashier and a sk them to g ive you change (gre edily). Sometimes this can result in clever sp ending; for ex ample if you hav e { 10 } and ar e charged 85 cents, then y ou’ll end up with { 25 } . How ever, in other ca ses this is so cially uncouth; if you have { 1 , 1 , 1 , 1 } a nd ar e charged 95 cents, then the ca shier will hand you ba c k { 5 , 1 , 1 , 1 , 1 } , which c o n tains the four p ennies you alrea dy had. With some thought, you can avoid alter cations b y not handing the cashier any coins they will ha nd rig h t back to you. In any cas e, if a minimalist s pender’s wallet has v alue n cents and the price is c cents, then the state of the wallet after the transac tion will b e a minimal partition of n − c mo d 1 00. Since there is o nly o ne such minimal pa rtition, this determines the minimalist sp ender’s wallet state. There are 1 0 0 po ssible wallet states, one for each integer 0 ≤ n ≤ 99. By assumption (1), the pro babilit y of transitioning fro m one s tate to any other state is 1 / 1 0 0, so no computation is necessar y to deter mine that each state is equally likely in the long ter m. The exp ected num b er of coins in the minimalist s pender’s wallet is therefor e 1 100 P 100 i =1 | s i | = 4 . 7, and the exp ected total v alue of the wallet is 1 100 P 99 n =0 n = 49 . 5 cents. Count ing o ccurrenc e s o f each denomination in the 1 00 minimal par titions o f 0 ≤ n ≤ 99 shows tha t the exp ected nu mber o f quarters is 1 . 5; the exp ected num b ers of dimes, nickels, and p ennies a re 0 . 8, 0 . 4 , and 2. Int uitively , one w ould exp ect the minimalist’s stra teg y to result in the low es t po ssible expected num b er of coins. Indeed this is the ca se; let g ( n ) b e the num ber of coins in the gr eedy pa rtition of n . Fix a spending strategy that yie lds an irr e ducible, ap erio dic Markov c hain. Let e ( n ) b e the long-term exp ected n umber of co ins in the sp ender’s wallet, conditiona l on the (long-ter m) total v alue b eing n cents. Since g ( n ) is the minimu m num b er o f coins r equired to hav e exa ctly n cents, e ( n ) ≥ g ( n ) for all 0 ≤ n ≤ 99 . Since the price c is uniformly distributed, the total v a lue n is uniformly dis tributed, and ther efore the long-ter m exp ected num b er of co ins is 1 100 99 X n =0 e ( n ) ≥ 1 100 99 X n =0 g ( n ) = 47 10 . How ever, the minimalist sp ender’s b ehavior is not very r ealistic. Supp ose the wallet state is { 5 } and the price is 79. F ew peo ple would hand the ca shier the nic kel in this situation, even tho ug h doing so would reduce the num b er of coins in their wallet a fter the transa ction by 2. So let us consider a mo re realistic strateg y . WHA T’S IN YOUR W ALLET? 5 The bi g sp ender. If a sp ender do es not hav e enough coins to cover the cost of their purchase and do es not need to achiev e the absolute minimum num ber of coins after the transaction, then the easie s t cour se of actio n is to s pend no coins. In addition to assumptions (1)–(2 ), let us therefore as sume the following. (3) If the sp ender doe s not ha ve sufficient change to pay for the purchase, he sp ends no coins and r eceives change from the cas hier. If the spender do es ha ve enough coins to cover the cost, it is rea sonable to assume that he ov erpays as little a s p ossible. F or example, if the wallet state is { 25 , 10 , 5 , 1 , 1 } and the price is 13 cents, then the sp ender sp ends { 1 0 , 5 } . How do es a s pender identify a s ubset of c oins whose total is the smallest total that is g reater than or equal to the purchase price? W ell, one w ay is to e x amine al l subsets of coins in the wallet and compute the total of ea c h. This naive algorithm may not be fast enoug h for the expr e ss la ne, but it turns out to b e fast enoug h to c o mpute the transition matr ix M in a reasona ble amount of time. Now, there may b e multiple subsets of coins in the wallet with the sa me minimal total. F or example, if the wallet state is { 1 0 , 5 , 5 , 5 } a nd the pric e is 15 cents, there are tw o w ays to make change. Using the greedy algorithm as inspiration, let us assume the sp ender bre a ks ties by fav oring bigge r co ins and spends { 1 0 , 5 } rather than { 5 , 5 , 5 } . Therefore we adopt the following a ssumptions. (4) If the sp ender has sufficient change, he makes the purchase by overpa ying as little as p ossible and r eceiv es change if necessary . (5) If ther e are multiple ways to ov erpay as little as p ossible, the s pender fav o rs { a 1 , a 2 , . . . , a m } ov e r { b 1 , b 2 , . . . , b n } , where a 1 ≥ a 2 ≥ · · · ≥ a m and b 1 ≥ b 2 ≥ · · · ≥ b n , if a 1 = b 1 , a 2 = b 2 , . . . , a i = b i and a i +1 > b i +1 for some i . W e refer to a sp ender who follows these rules as a big sp ender . Let’s chec k that there a re only finitely many states for a big s p ender’s wallet. Lemma. Supp ose a sp en der adher es to assum ptions (3) and (4) . If the sp ender’s wal let has at most 99 c ents b efor e a tr ansaction, then it has at most 99 c ents after the tr ansaction. Pr o of. Let 0 ≤ c ≤ 99 be the price, and let n b e the total v a lue of coins in the sp ender’s wallet. If c ≤ n , by (4) , the sp ender pays at lea st c cents, receiving change if necessary , and ends up with n − c c e n ts after the tr ansaction. Since n ≤ 9 9 and c ≥ 0, w e know that n − c ≤ 9 9 as well. If c > n , since n is not enough to pay c cents, by (3) the sp ender only pays with bills, and rec e iv es 100 − c in change, for a total o f n + 100 − c = 10 0 − ( c − n ) after the transaction. Since c > n , we know that c − n ≥ 1 , so 100 − ( c − n ) ≤ 99. If a big sp ender b egins with more than 9 9 cen ts in his wallet (b ecause he did well at a slo t machine), then he will sp end coins unt il he ha s at most 99 cents, and then the lemma applies. Thus a n y wallet state with more than 99 cents is only transient and has a long-term pro ba bilit y of 0. Since there are finitely many wa ys to carr y around a t most 99 cents, the state s pace of the big sp ender’s wallet is finite. W e a re now rea dy to set up a Marko v c hain for the big sp ender. The p ossible wallet s ta tes are the states totaling at mos t 99 cen ts. E ac h such state cont ains at most 3 q uarters, 9 dimes, 1 9 nick els, and 99 p ennies, and a q uic k computer filter shows that o f these 4 × 10 × 20 × 100 = 80000 p otential states only 672 0 contain at most 9 9 cents. 6 LARA P UD WELL AND ERIC RO WLAND T o construct the 6720 × 67 20 transition ma tr ix for the big sp ender Marko v c hain, we must simulate all 6720 × 100 = 67200 0 p ossible transa ctions. This is where the use of a computer b ecomes imp erative. Since we ar e using the na iv e algor ithm, simulating this man y tra nsactions is somewhat time-consuming. The authors’ im- plement ation to ok 8 ho urs on a 2.6 GHz laptop. The list o f wallet states and the explicit trans itio n matrix can b e downloaded fro m the authors’ web sites, alo ng with a Mathematic a notebo ok containing the computations. F rom the Perron–F rob enius theorem, we know that the limiting distr ibutio n p exists. Howev er , computing it is another matter. F or matrices of this size, Gaussian elimination is slow. If w e don’t ca re ab out the entries of p a s exact rational n umbers but ar e conten t with approximations, it’s muc h faster to use nu merical metho ds . A rnoldi iter ation is an efficient metho d for appr o ximating the lar gest eigenv a lues and asso ciated eig en vectors o f a matrix, without c o mputing them all. An implementation of Arno ldi iteration due to Lehoucq and So rensen [8] is av ailable in the pa ck age ARP ACK [12 ], which is free to download and use. This pack ag e is also used by Mathematic a [1 5], so to compute the dominant eigenv ector of a matrix one can simply ev a luate Eigenv ectors[ N[Transpose[ matr ix ]], 1] in the W olfra m Languag e. The symbol N converts rational en tries in the matr ix to floating-p oint num b ers, and Tr anspose ensure s that we get a left (not right) eigenv ector. ARP ACK is quite fast. Computing the dominant eigenv ector for the big sp ender transition matr ix takes less than a seco nd. And one finds that there ar e five most likely states, e ac h with a probability of 0 . 01000; they are the empty wallet {} and the states consisting of 1, 2 , 3, or 4 p e nnies. Therefore 5% of the time the big sp ender’s wallet is in one o f these states. The expec ted num b er of coins in the big sp ender’s wallet is approximately 10 . 0 5. This is more than twice the exp ected num b er of co ins for the minimalist sp ender. The exp ected nu mbers of qua rters, dimes, nick els , and p ennies are 1 . 0 6 , 1 . 15 , 0 . 91, and 6 . 92. Assuming that all coin holders are big sp enders (which is no t actually the case, s ince cas h reg isters disp ense coins greedily), this implies that the distri- bution of co ins in circula tion is 10 .6 % qua r ters, 1 1.5% dimes, 9.1% nick els, and 68.9% p ennies. Compar e this to the dis tribution of U.S. minted coins in 2014 — 11.9% qua rters, 17.4% dimes, 9 .1% nick els, and 61.6% p ennies. Relative to the coin keeper stra tegy , the big sp ender distr ibution comes several times clo ser (as p oin ts in R 4 ) to the U.S. mint distr ibution. The exp ected tota l v a lue of the big sp ender’s wallet is computed to be 49 . 5 cen ts. This is the same v alue as for the minimalist sp ender, which may b e surprising since the t wo sp ending strategies are so differe nt. How ever, it is a conseq ue nce o f assumption (1) , which sp ecifies that prices are dis tributed uniformly . If we ig nore all informatio n ab out the big sp ender’s wallet sta te except its v alue, then we get a Ma rk ov chain with 100 states, all equally likely , and the exp ected wallet v alue is 49 . 5 cents. Since the exp ected wallet v alue is preserved under the function which forgets ab out the particular par tition of n , the big sp ender has the same exp ected wallet v alue. In fact, any sp ending scenario in which the p ossible wallet v alues a re all equally likely has an exp ected wallet v a lue equal to the average of the p ossible wallet v alues. WHA T’S IN YOUR W ALLET? 7 The p ennies-first big sp ender. W e hav e seen that while the minimalist sp ender carries 4 . 7 coins on av er age, the big spe nder car ries sig nifican tly mor e. W e can narrow the gap by sp ending p ennies mo re intelligen tly . F or example, if the wallet state is { 1 , 1 , 1 , 1 } and the pr ice is 99 ce n ts, then it is easy to se e that s pending the four p ennies will r esult in fewer coins than not. T o determine which coins to pa y with, the p ennies-first big sp ender first computes the price mo dulo 5. If he has enough pe nnies to cov er this pr ice, he hands those pennies to the cashier a nd subtra cts them from the price. Then he b e ha ves as a big sp ender, paying for the mo dified price. If the p ennies-first big sp ender has fewer than 5 p ennies b efore a tra ns action, he has fewer than 5 p ennies after the transactio n. Ther e fo re the p e nnies -first big sp ender never carries more than 4 pennies, a nd the state space is reduced to o nly 1065 states. Computing the dominant eigenv ector of the transitio n matrix s ho ws that the exp ected num b e r of coins is 5 . 74. This is only 1 coin more than the minim um p ossible v alue, 4 . 7. So sp ending pennies first actually gets you q uite close to the few est co ins on average. The exp ected nu mbers of qua rters, dimes, nick els , and p ennies for the pennies - first big sp ender a re 1 . 12, 1 . 27 , 1 . 35, a nd 2 . 00. This rais e s a question. Is the exp ected num b er of p ennies not just approximately 2 but exa ctly 2? Imagine that the p ennies-first big sp ender is actually t wo p eople, one who holds the p ennies, and the o ther who ho lds the quarter s , dimes, and nic kels. When presented with a price c to pay , these tw o p eople can b ehav e collectively a s a p ennies-first big sp ender without the pe nny holder receiving infor ma tion fro m his partner. If the penny holder can pay for c mo d 5, then he do es; if not, he receives 5 − ( c mo d 5) pennies from the cas hier . Since the pe nn y holder do esn’t need any infor mation from his par tner, all five pos sible states a re equally likely , and the e x pected num b er of p ennies is exa ctly 2. Other currencies The framework we hav e outlined is certainly applica ble to o ther curr e ncies. W e men tion a few of interest, retaining as s umptions (1)–(5). A p enniless pur chaser is a sp ender who has no money . Unless they get a job, their long-ter m wallet b eha vior is not difficult to analyze. O n the other hand, a p ennyless pur chaser is a big sp ender who nev er carries p ennies but do es carr y other coins. Penn yless pur chasers arise in at least t wo different wa ys. Some governmen ts prefer not to deal with pennies. Canada , for exa mple, stopp ed minting p ennies as of 201 2 , so most tr ansactions in Canada no long er in volv e pe nnies . On the o ther hand, some p eople prefer no t to deal with p ennies and drop a ny they receive into the give-a-p enny/tak e-a-p enny tr a y . Therefor e prices for a p ennyless purchaser are effectively rounded to a multiple of 5 cen ts, and it s uffices to conside r 2 0 prices ra ther than 100. Moreov er, these 20 prices o ccur with equal frequency as a cons equence of assumption (1). There ar e 213 wallet states comp osed of quar ters, dimes, a nd nick els that hav e v alue at mos t 9 9 cents. The expec ted num b ers of quarter s, dimes, and nickels fo r the p ennyless purchaser ar e 1 . 1 2, 1 . 2 7 , a nd 1 . 35. If these num b ers lo ok familiar, it is b ecause they are the s ame num b ers we co m- puted for the p ennies-first big s pender! Since we established that p ennies ca n b e mo deled independently of the other coins for the pennies -first big sp ender, one 8 LARA P UD WELL AND ERIC RO WLAND might susp ect that the p ennies-first big sp ender ca n be decomp o sed int o tw o in- depe ndent compo nen ts — a p enn yless purchaser (with 213 states) and a p enny holder (with 5 states, all equally likely). When presented with a price c to pay , the pennyless compo nen t pa ys for c − ( c mo d 5) as a big s pender, receiv ing change in quarters, dimes, a nd nic kels if necessa ry . As b efore, if the p enny holder ca n pay for c mod 5, then he do es; if not, he receives 5 − ( c mo d 5) pennies in change. Let us call the pro duct of these indep enden t comp onents a p ennies-sep ar ate big sp ender . How ever, this decomp osition do esn’t actually work. F or the pennies- first big sp ender, if the price is c = 1 cent then the tw o wallet states { 5 } a nd { 5 , 1 } result in different num b ers o f nick els a fter a transa c tio n, so the pennyless comp onen t do es in fact need informatio n from the p enny comp onent. E ven worse, if the price is c = 1 cent and the wallet is { 5 } then the p ennies- sep ar ate big s pender’s wallet b ecomes { 5 , 1 , 1 , 1 , 1 } , which is to o muc h change! Nonetheless, these tw o Markov chains ar e clo sely rela ted. Suppos e s i and s j are t wo states such that so me price c causes s i to transition to s j for the p ennies-first big sp ender. If s i contains fewer than c mo d 5 p ennies, then the price ( c + 5) mo d 100 causes s i to trans itio n to s j for the pennies-s eparate big sp ender; otherwise the price c causes this tr ansition. Therefore the transition matr ices for the p ennies- first big sp ender and the p e nnies-separate big sp ender ar e equa l, and this explains the num erica l coinc idenc e w e observed. Another s p ending strateg y is the quarter ho ar der , used by co llege students and apartment dwellers who save their quarters for laundry . All quar ters they r eceiv e as change are immediately thrown in to their laundry funds. Of the 10 × 20 × 1 00 = 20000 p otential wallet states containing up to 9 dimes, 19 nic kels, and 99 p ennies, there a re 4125 states for which the total is at most 99 cents. The exp ected num b er of coins for a big spender quarter hoar der is 13 . 74, distributed as 1 . 60 dimes, 1 . 21 nick els, and 10 . 9 3 p ennies. Finally , let’s co nsider a currency no one actually uses . Under assumptions (1) and (2), Shallit [13] a sk ed how to c ho ose a curre nc y so that cashiers retur n the few est coins p er tra nsaction on av erage . F o r a c ur rency d 1 > d 2 > d 3 > d 4 with four denominations, he c omputed that the minimum p ossible v alue for the av erage nu mber of co ins per transa ction is 389 / 100, and one wa y to attain this minim um is with a 25- cen t piece, 18-cent piece , 5-cent piece, and 1-cent piece . So as our final mo del, w e co ns ider a fictional country that has a dopted Shallit’s sug gestion of r eplacing the 10- cen t piece with an 18-cent piece. The r e a re tw o pro perties of this curr ency that the U.S. curre nc y do es not hav e. T he first is that the gr e edy algorithm do esn’t alwa ys mak e change using the few est p ossible coins. F or example, to make 28 cents the greedy algo rithm g iv es { 25 , 1 , 1 , 1 } , but you can do b e tter with { 18 , 5 , 5 } . The second pr oper t y is that there is not always a unique way to make change using the few est p ossible co ins . F or example, 7 7 cents can b e g iv en in five coins as { 2 5 , 25 , 25 , 1 , 1 } or { 18 , 18 , 1 8 , 18 , 5 } . The pr ic es 8 2 and 9 5 also hav e m ultiple minimal repres en tations. (Bryan t, Hamblin, and Jones [2 ] give a characteriz a tion of c ur rencies d 1 > d 2 > d 3 that av o id this prop ert y , but for more than three denominations no simple characterizatio n is known.) Accor ding to assumption (5 ), the big sp ender breaks ties b e t ween minimal repr esen tations of 77, 82, a nd 95 by fav o r ing bigger coins. F or exa mple, the big s pender s p ends { 25 , 25 , 2 5 , 1 , 1 } r a ther than { 1 8 , 18 , 18 , 1 8 , 5 } if b oth are p ossible. WHA T’S IN YOUR W ALLET? 9 The cashier do esn’t car e ab out g etting r id of big coins, howev er . So to make things interesting, let’s refine assumption (2) as follows. (2 ′ ) Cashiers return change using the fewest po ssible coins; when there are tw o wa ys to make change with fewest coins, the cashier uses each half the time. F or ex a mple, a cashier makes c hange for 77 cents as { 25 , 2 5 , 25 , 1 , 1 } with probability 1 / 2 and as { 18 , 18 , 18 , 18 , 5 } with probability 1 / 2. Co ns equen tly , the transition matrix has some entries that are 1 / 20 0 . F or the minimalist sp ender in this curr ency , there ar e 100 p ossible wallet s tates, and the exp e cted n umber of coins is 1 100 P 100 i =1 | s i | = 3 . 8 9 . Note that this is the same computation used to determine the av era g e n umber of coins p er tr a nsaction. In gener al these t wo quantities are the same, so r educing the num b er o f coins p er transaction is equiv ale nt to reducing the num b er of coins in the minimalist sp ender’s wallet. Relative to the U.S. cur rency , the minimalis t sp ender c a rries 0 . 8 1 few er coins in the Shallit cur rency . The num be r o f wallet s tates in the Shallit cur rency totaling at most 99 cent s is 4238. The pennies -first big sp ender stra tegy is no t such a s ensible way to sp end coins, since if your wallet state is { 1 8 , 1 , 1 , 1 } and the price is 1 8 cents then you don’t wan t to sp end p ennies first. F o r the big sp ender, howev e r, the exp ected num b er of coins is 8 . 63 , so this curre ncy also reduces the num b er of coins in the wallet of a big sp ender. The exp ected n umbers o f quarters, 1 8-cent pieces, nick els, a nd p ennies are 0 . 6 6, 0 . 9 8 , 2 . 10, and 4 . 89 . Cashing in In this pap er, we have taken the question ‘What’s in your wallet?’ quite literally . W e deter mined the long-term b ehavior of wallets with v a rious currencies under four sp ending strategies — the co in keepe r , the minimalist s pender, the big sp ender, and the p e nnies-first big sp ender. Numerica l metho ds in linear a lgebra afford us acces s to this statistical information — information that is arguably interesting to know and that may no t b e obtainable any simpler wa y . How ever, while Arnoldi iteration allows us to quickly compute the dominant eigenv ector of a transition matrix, the computation of the matrix itse lf can b e time-consuming. W e used the naive a lgorithm for simulating a transaction, which lo oks at all subsets of a wallet to determine which s ubs et to s p end. Is there a faster algorithm fo r co mputing, for exa mple, the big sp ender’s b eha vior? There are many curre nc ie s we hav e not co ns idered. It would b e int eresting to know in which country o f the world a big sp ender (or a smalle s t-denomination-first big sp ender) is exp ected to carry the few est coins. Or , which cur rency d 1 > d 2 > d 3 > d 4 of fo ur denominations minimizes the exp e cted n umber of coins in your wallet? There ar e als o sp ending str ategies we hav e no t cons ide r ed, a nd indeed there a r e go o d reasons to v a ry some of the assumptions. F or example, assumption (5) is n’t universally true. Giv en the choice b et ween s p ending a dime or tw o nickels, the big sp ender sp ends the dime. While the big sp ender minimizes the num b er of coins he sp ends, another sp ender might instead break ties by spending m or e coins. W e could consider a he avy sp ender who maximizes the num b er of co ins sp en t from his wallet in a g iv en transa ction acco rding to the fo llowing mo dification of assumption (5). (5 ′ ) If there are multiple ways to ov erpay as little as p ossible, the s p ender fav or s { a 1 , a 2 , . . . , a m } ov er { b 1 , b 2 , . . . , b n } if m > n . 10 LARA P UD WELL AND ERIC RO WLAND A heavy sp ender fav ors { 5 , 5 } over { 1 0 } . Do ass umptions (3), (4), a nd (5 ′ ) com- pletely determine the b ehavior o f a heavy sp ender? If so, how muc h ligh ter is the heavy sp ender’s wallet? Of co urse, the million-dollar question is whether typical p eople use any of these sp ending str ategies. How many co ins is an actual p erson exp ected to carry? Do es a typical p erson hav e a consistent spe nding strategy , or do es their b eha vior dep end more on how m uch of a rush they’re in? If some p eople do us e a consistent strateg y , to wha t extent is the p ennies-first big sp ender mo re rea listic than the big sp ender? On s e c ond thought, maybe it’s just ea sier to us e your cre dit car d. References [1] Anna Adamaszek and M ic hal Adamaszek, Com binatorics of the c hange-making problem, Eur op e an Journal of Combinatorics 3 1 (2010) 47–63. [2] Lance Bry an t, James Hamb lin, and Lenn y Jones, A v ariation on the money-c hanging problem, The Americ an M athematic al M onthly 119 (2012) 406–414. [3] Xuan Cai, Canonical coin systems for c hange-making problems, Pr o c e e dings of the Ninth International Confer enc e on Hybrid Intel ligent Syste ms 1 (2009) 499–504. [4] Lena Chang and James F. Korsh, Canonical coin changing and greedy solutions, Journal of the Asso ciation for Computing Machinery 23 (1976) 418–422. [5] S. K. Chang and A. Gil l , Algorithmic solution of the change -making problem, Journal of the Asso ciation for Computing Machinery 17 (1970) 113–122. [6] John Dewey Jones, Or derly curr encies, The A meric an Mathematic al Monthly 101 (1994) 36–38. [7] Dexter Kozen and Shmuel Zaks, Optimal b ounds for the change -making problem, The or e tic al Computer Sci enc e 123 (1994) 377–388. [8] Richard B. Lehoucq and Danny C. Sorensen, D eflat ion tech niques for an impli citly restarted Arnoldi i teration, SIAM Journal on Matrix Analysis and Applic ations 17 (1996) 789–821. [9] M. J. Magazine, G. L. Nemhauser, and L. E. T rotter, Jr., When the greedy solution s ol v es a class of knapsack problems, Op er ations R ese ar ch 23 (1975) 207–217. [10] Stephen B. Maurer, Disorderly currencies, The Americ an Mathematic al Monthly 101 (1994) 419. [11] Dav id Pearson, A polynomial- time algorithm for the change-making pr oblem, Op er ations R ese ar ch L etters 33 (2005) 231–234. [12] Rice Univ ersity , ARP ACK, http://www.c aam.rice.edu/software/ARPACK/ . [13] Jeffrey Shallit, What this coun try needs is an 18 ¢ piece, The Mathematic al Intel ligenc e r 2 5 (2003) 20–23. [14] United States Mint , Pro duction and sales figures, http://www .usmint.gov/ about_the_mint/?action=coin_production . [15] W olfr am Researc h, Some notes on internal implementation, http://r eference.wol fram.com/language/tutorial/SomeNotesOnInternalImplementation.html#15781 . Dep ar tment of Ma thema tics and S t a tistics, V alp araiso University, V alp araiso, In di- ana 463 83, USA LaCIM, University of Qu ´ ebec a t Montr ´ eal, Montr ´ eal, QC H2X 3Y7, Canada Curr ent addr e ss : D epartment of Mathematics, Unive rsity of Li ege, 4000 Li` ege, Belgium
Original Paper
Loading high-quality paper...
Comments & Academic Discussion
Loading comments...
Leave a Comment