## Le Monde puzzle [#1053]

Posted in Books, Kids, R with tags , , , , , , , on June 21, 2018 by xi'an

An easy arithmetic Le Monde mathematical puzzle again:

1. If coins come in units of 1, x, and y, what is the optimal value of (x,y) that minimises the number of coins representing an arbitrary price between 1 and 149?
2.  If the number of units is now four, what is the optimal choice?

The first question is fairly easy to code

```coinz <- function(x,y){
z=(1:149)
if (y<x){xx=x;x=y;y=xx}
ny=z%/%y
nx=(z%%y)%/%x
no=z-ny*y-nx*x
return(max(no+nx+ny))
}```

and returns M=12 as the maximal number of coins, corresponding to x=4 and y=22. And a price tag of 129.  For the second question, one unit is necessarily 1 (!) and there is just an extra loop to the above, which returns M=8, with other units taking several possible values:

```[1] 40 11  3
[1] 41 11  3
[1] 55 15  4
[1] 56 15  4
```

A quick search revealed that this problem (or a variant) is solved in many places, from stackexchange (for an average—why average?, as it does not make sense when looking at real prices—number of coins, rather than maximal), to a paper by Shalit calling for the 18¢ coin, to Freakonomics, to Wikipedia, although this is about finding the minimum number of coins summing up to a given value, using fixed currency denominations (a knapsack problem). This Wikipedia page made me realise that my solution is not necessarily optimal, as I use the remainders from the larger denominations in my code, while there may be more efficient divisions. For instance, running the following dynamic programming code

```coz=function(x,y){
minco=1:149
if (x<y){ xx=x;x=y;y=xx}
for (i in 2:149){
if (i%%x==0)
minco[i]=i%/%x
if (i%%y==0)
minco[i]=min(minco[i],i%/%y)
for (j in 1:max(1,trunc((i+1)/2)))
minco[i]=min(minco[i],minco[j]+minco[i-j])
}
return(max(minco))}
```

returns the lower value of M=11 (with x=7,y=23) in the first case and M=7 in the second one.

## revenge, death penalty, prisons, &tc.

Posted in Books, Kids, University life with tags , , , , , , , , , on May 17, 2014 by xi'an

In the latest Sunday Review of the New York Times, the Norwegian novelist Jo Nesbo has a tribune on revenge against misdeeds and law as institutionalized revenge. Somewhat hidden in the current justifications of the legal system(s). (As an aside, he mentions the example of the Icelandic Alþingi where justice was dispensed once a year, resulting in beheadings, stake burnings, and drowning in the pond depicted above…) This came a few days after another tribune on a similar topic by Charles Blow, following the “botched Oklahoma execution of Clayton Lockett”, entitled “Eye-for-eye incivility” (an understatement if any!), and arguing  about the economic inefficiency of the death penalty. Besides the basic moral quandaries of taking someone else’s life, perfectly summarised by Franquin in the following dark strip:

This sequence of tribunes links to one of my pet theories, which is that imprisonment is the most inadequate way of addressing crime and law breaking in (modern?) societies.  Setting fully aside the moral notions of revenge and punishment, which aim more at the victim or victim’s relatives than at the perpetrator, and of redemption and remorse, which are at best hypothetical and inspired by religious considerations,  I do wonder why economists have not tried to come up with more rational and game-theoretic ways of dealing with law-breakers than locking them up all together and expecting them to behave forever after the end of their term. More globally, I find it quite surprising that no one ever seems to question the very notion of sending people to jail. Indeed, it does bring any clear benefit to society as a whole. One of the usual arguments I receive in those occasions is that imprisonment keeps dangerous people away. But that seems a fairly weak notion: (i) most violent offenders are not dangerous in an absolute berserker sense but only because local circumstances made them violent at a given occurrence in space and time, (ii) those offenders are only put away for a while (in most civilised countries), (iii) they are not getting any less dangerous while in prison, and (iv) it does not apply to the vast majority of people jailed. Furthermore, from a pure offer-versus-demand perspective, this may be counterproductive: e.g., putting some thieves away in jail for a while simply gives an opportunity to other thieves to take advantage of the “thieving market”.

The Freakonomics blog has some entries on the topic—somewhat supportive of my notion that most criminals act in an overall rational way for which incentives and decentives could be considered—, but still fails to address the larger picture… I showed this post to Andrew who pointed me (of course!) to his blog, as several entries therein also consider the issue, like this one on the puzzles of criminal justice. Or prison terms for financial fraud? But I would push the argument further and call for an ultimate abolishment of the carceral system, seeking efficient and generalised alternatives to imprisonment. As detailed in this U.N. report I just came across. As I think a time will come when imprisonment will be seen as irrational as witch-burning is considered today.

## Clockers [book review]

Posted in Books, Travel with tags , , , , , , , , , on March 15, 2014 by xi'an

Throughout my recent trip to Canada, I read bits and pieces of Clockers by Richard Price and I finished reading it last Sunday. It is an impressive piece of literature and I am surprised I was not aware of its existence until amazon.com suggested it to me (as I was checking for recent books by another Richard, Richard Morgan!). Guessing from the summary it could be of interest and from comments it was sort of a classic, I ordered it more or less on a whim (given a comfortable balance on my amazon.com account, thanks to ‘Og’s readers!) It took me a few pages to realise the plot was deeply set in the 1990’s, not only because this was the high of the crack epidemics, but also since the characters (drug dealers and policemen) therein are all using beepers, instead of cellphones, and street phone booths).

“It’s like a math problem. Juan got whacked at point X, he drove away losing blood at the rate of a pint every ninety seconds. He was driving forty-five miles an hour and he bought the farm two miles inside the tunnel (…) So for ten points, [who] in what New Jersey town did Juan?” Clockers (p.272)

The plot of Clockers is vaguely a detective story as an aging and depressed homicide officer, Rosso, hunts the murderer of a drug dealer, being convinced from the start that the self-declared murderer Victor did not do it. In parallel, and somewhat more closely, the book follows the miserable plight and thoughts and desires of Victor’s brother, Strike, who is head of a local crack dealing network, under the domination of the charismatic and berserk Rodney Little… But the resolution of the crime matters very little, much less than the exposure of the deadly economics of the drug traffic in inner cities (years before Freakonomics!), of the constant fight of single mothers to bring food and structure to their dysfunctional families, to the widespread recourse to moonlighting, and above all to the almost physical impossibility to escape one’s environment (even for smart and decent kids like Victor and, paradoxically enough, the drug-dealing Strike) by lack of prospect and exposure to anything or anywhere else, as well as social pressure, early pregnancies and gang-related micro-partitioning of cities.

When I mentioned Clockers to Andrew, he told me that he also liked it very much but that the characters were not quite “real”. I somewhat agree in that, while the economics, the sociology and the practice of drug-dealing sound very accurately reproduced (for all I know!), the characters are more caricaturesque or picturesque than natural. The stomach disease of Strike sounds too much like an allegory of both his schizophrenic split between running the drug trade and looking for a definitive quit, while the sacrifice of his brother makes little sense, except as a form either of suicide or of escape from an environment he can no longer stand. What is most surprising is that Richard Price (just like Michael Crichton) is  a practised screenwriter (who collaborated to Spike Lee’s 1995 Clockers). So he knows how to run an efficient story with convincing characters and plot(s). Hence my little theory of a picaresque novel… (Here is Jim Shepard’s enthusiastic review of Clockers. With the definitely accurate title of “Sympathy for the dealer”.)

## weakonomics

Posted in Books, Statistics, University life with tags , , , , , , on February 4, 2013 by xi'an

Believe it or not, I had never read Freakonomics..! Therefore, when I saw the book on sale for a negligible price in Dehli Airport—great airport by the way!—, I went for it. Having now read a fair chunk of the book (or unfair chunk, see below!) within two days (during my metro rides), I am rather disappointed by the content and thus puzzled by the then-craze about the book. (Andrew just loved it!) Freakonomics is certainly a well-designed product from a salesman perspective and it thus reads pleasantly enough, but I find it remains at too much of a superficial level. In addition, it sometimes sounds as if the authors have a hidden agenda (more later)! (Now, of course, my reaction of the book is completely irrelevant as it comes very late after the publication in 2005. So, reader,  stop here if you do not want to waste time any further!)

“…if the death penalty were assessed to anyone carrying an illegal gun, and if the penalty were actually enforced, gun crimes would surely plunge.” (p.118)

To wit, the way the book is written sounds much more journalistic than academic: the authors take an economic study or paper about an unusual (freakish) topic and weave a nice story around it, always with the intent of showing “conventional wisdom” is wrong. Since this is a general public book, there is no theory behind the story and it all seems to flow from “common sense”: yes, most drug dealers do not earn enough to make a living because the corporate structure of the drug economy is highly hierarchical and as highly biased towards higher levels. The only foray into theory, namely the discussion about factors impacting kids success rate at school, casts doubts about regression and the distinction between causation and correlation is never truly investigated (even though the mantra correlation is not causation is found therein often enough!). Moreover, by resorting to the journalistic trick of making everything very personal (so-and-so went to drug dealer housing projects for six years, so-and-so decided to re-analyse the school records in Chicago, &tc.), the authors actually lower the credentials of their theories. If so-and-so found this effect, maybe there is another or an hundred others so-and-so going the opposite way! But those others are not mentioned as the book retains this flatland and Unitarian perspective… And the conclusions are anti-climactic: when so-and-so gets hold of the ledgers of a crack dealing gang, the description stops at reporting the hierarchical structure of the organisation and the revenues of the different levels. No major theory appears to be tested. At least within the book.

“Given the number of handguns in the United States (…), the probability that a particular gun was used to kill someone that year is 1 in 10,000. The typical gun buyback yields fewer than 1,000 guns—which translates into an expectation of less than one-tenth of one homicide per buyback.” (p.121)

The above quote puzzled me for a while, until I formalised the experiment as an hypergeometric draw of 1000 guns from a population of almost 300 millions guns, out of which more than 10,000 are crime guns. (The probability that a particular gun is used for a crime is then 1 in 30,000.) And the probability to draw at least one of those guns in one buyback is then approximately 0.03. But this seems to miss the other side of the equation, namely the worth of a human life. (Not that I believe that gun buybacks are particularly effective since, as noted by the authors, they mostly attract “heirldom or junk” (p.121).)

A minor disappointment was to stumble upon the conclusion of the book in…its very middle! I first thought I was confused and this was only the conclusion to a section but no, the second half of the book as I bought it was made of extracts from the authors’ column in the New York Time and of their blog, getting close to a swindle in my opinion! Or at least being the unfair chunk mentioned above. I also find annoying (and so does Andrew!) this insistence upon being rogue economists, as advertised on the front cover of the book, as the authors have shown themselves to be very efficient economists by turning the freakonomics idea into a whole business: books, films, videos, lectures, &tc. Nothing to complain about, except for the rogue label. (Note that they should have registered the franchise as well, given the subsequent profusion of -omics books and sites, from the fantastic Freakonometrics blog of my former colleague Arthur Charpentier, to Soccernomics I recently bought for my son…)