Archive for the Kids Category

Le Monde puzzle [#1063]

Posted in Books, Kids, R with tags , , , , , , on August 9, 2018 by xi'an

lemondapariA simple (summertime?!) arithmetic Le Monde mathematical puzzle

  1. A “powerful integer” is such that all its prime divisors are at least with multiplicity 2. Are there two powerful integers in a row, i.e. such that both n and n+1 are powerful?
  2.  Are there odd integers n such that n² – 1 is a powerful integer ?

The first question can be solved by brute force.  Here is a R code that leads to the solution:

isperfz <- function(n){ 
  for (i in 1:length(facz)) 

for (t in 4:1e5)
if (isperfz(t)) lesperf=c(lesperf,t)

with solutions 8, 288, 675, 9800, 12167.

The second puzzle means rerunning the code only on integers n²-1…

[1] 8
[1] 288
[1] 675
[1] 9800
[1] 235224
[1] 332928
[1] 1825200
[1] 11309768

except that I cannot exceed n²=10⁸. (The Le Monde puzzles will now stop for a month, just like about everything in France!, and then a new challenge will take place. Stay tuned.)

Is that a big number? [book review]

Posted in Books, Kids, pictures, Statistics with tags , , , , , , , , , on July 31, 2018 by xi'an

A book I received prior to its publication a few days ago from OXford University Press (OUP), as a book editor for CHANCE (usual provisions apply: the contents of this post will be more or less reproduced in my column in CHANCE when it appears). Copy that I found in my mailbox in Warwick last week and read over the (very hot) weekend.

The overall aim of this book by Andrew Elliott is to encourage numeracy (or fight innumeracy) by making sense of absolute quantities by putting them in perspective, teaching about log scales, visualisation, and divide-and-conquer techniques. And providing a massive list of examples and comparisons, sometimes for page after page… The book is associated with a fairly rich website, itself linked with the many blogs of the author and a myriad of other links and items of information (among which I learned of the recent and absurd launch of Elon Musk’s Tesla car in space! A première in garbage dumping…). From what I can gather from these sites, some (most?) of the material in the book seems to have emerged from the various blog entries.

“Length of River Thames (386 km) is 2 x length of the Suez Canal (193.3 km)”

Maybe I was too exhausted by heat and a very busy week in Warwick for our computational statistics week, the football  2018 World Cup having nothing to do with this, but I could not keep reading the chapters of the book in a continuous manner, suffering from massive information overdump! Being given thousands of entries kills [for me] the appeal of outing weight or sense to large and very large and humongous quantities. And the final vignette in each chapter of pairing of numbers like the one above or the one below

“Time since earliest writing (5200 y) is 25 x time since birth of Darwin (208 y)”

only evokes the remote memory of some kid journal I read from time to time as a kid with this type of entries (I cannot remember the name of the journal!). Or maybe it was a journal I would browse while waiting at the hairdresser’s (which brings back memories of endless waits, maybe because I did not like going to the hairdresser…) Some of the background about measurement and other curios carry a sense of Wikipediesque absolute in their minute details.

A last point of disappointment about the book is the poor graphical design or support. While the author insists on the importance of visualisation on grasping the scales of large quantities, and the webpage is full of such entries, there is very little backup with great graphs to be found in “Is that a big number?” Some of the pictures seem taken from an anonymous databank (where are the towers of San Geminiano?!) and there are not enough graphics. For instance, the fantastic graphics of xkcd conveying the xkcd money chart poster. Or about future. Or many many others

While the style is sometimes light and funny, an overall impression of dryness remains and in comparison I much more preferred Kaiser Fung’s Numbers rule your world and even more both Guesstimation books!

Le Monde puzzle [#1062]

Posted in Books, Kids, pictures, R with tags , , , , , on July 28, 2018 by xi'an

lemondapariA simple Le Monde mathematical puzzle none too geometric:

  1. Find square triangles which sides are all integers and which surface is its perimeter.
  2. Extend to non-square rectangles.

No visible difficulty by virtue of Pythagore’s formula:

for (a in 1:1e4)
for (b in a:1e4)
  if (a*b==2*(a+b+round(sqrt(a*a+b*b)))) print(c(a,b))

produces two answers

 5 12
 6  8

and in the more general case, Heron’s formula to the rescue!,

for (a in 1:1e2)
for (b in a:1e2)
for (z in b:1e2){
  if (abs(4*s-abs((s-a)*(s-b)*(s-z)))<1e-4) print(c(a,b,z))}


 4 15 21
 5  9 16
 5 12 13
 6  7 15
 6  8 10
 6 25 29
 7 15 20
 9 10 17

and it only gets worse…

Posted in Kids, pictures with tags , , , , , , , , , , , , , , , , , , , , , , , on July 23, 2018 by xi'an

“David Brooks, the New York Times columnist, recently summed up the “Trumpian world-view” writing, “Trump takes every relationship that has historically been based on affection, loyalty, trust and reciprocity and turned it into a relationship based on competition, self-interest, suspicion and efforts to establish dominance.” NYT, June 14

“Donald Trump has dismissed concerns about the widely condemned human rights record of the North Korean dictator, Kim Jong-un, praising him as a “tough guy”, a “smart guy” and a “great negotiator”.” The Guardian, June 14

“Clinics that call themselves crisis pregnancy centers are not obliged to tell women when state aid may be available to obtain an abortion, according to a US supreme court ruling that represents a blow to pro-choice groups (…) All three of the court’s female members dissented.” The Guardian, June 27

“A resolution to encourage breast-feeding was expected to be approved quickly and easily by the (…) United Nations-affiliated World Health Assembly. Based on decades of research, the resolution says that mother’s milk is healthiest for children and countries should strive to limit the inaccurate or misleading marketing of breast milk substitutes. Then the United States delegation, embracing the interests of infant formula manufacturers, upended the deliberations. The intensity of the administration’s opposition to the breast-feeding resolution stunned public health officials and foreign diplomats, who described it as a marked contrast to the Obama administration.” NYT, July 8

“President Trump on Tuesday pardoned a pair of Oregon cattle ranchers who had been serving out sentences for arson on federal land (…) The pardons undo an Obama administration appeal to impose longer sentences for the Hammonds and show that, at least in this case, the Trump administration is siding with ranchers in the battle over federal lands.” NYT, July 10

“President Trump stood next to President Vladimir V. Putin of Russia on Monday and publicly challenged the conclusion of his own intelligence (…) “No prior president has ever abased himself more abjectly before a tyrant,” Senator John McCain, Republican of Arizona, said in a statement. “Today’s press conference in Helsinki was one of the most disgraceful performances by an American president in memory.” ” NYT, July 16

“The Interior Department on Thursday proposed the most sweeping set of changes in decades to the Endangered Species Act, the law that brought the bald eagle and the Yellowstone grizzly bear back from the edge of extinction but which Republicans say is cumbersome and restricts economic development.” NYT, July 20

Le Monde puzzle [#1061]

Posted in Books, Kids, R with tags , , , , , on July 20, 2018 by xi'an

lemondapariA griddy Le Monde mathematical puzzle:

  1. On a 4×5 regular grid, find how many nodes need to be turned on to see all 3×4 squares to have at least one active corner in case of one arbitrary node failing.
  2.  Repeat for a 7×9 grid.

The question is open to simulated annealing, as in the following R code:


  for (i in (1:length(grue))[grue==1]){

   for (t in 1:T){
     if (max(grue)==1){ grue[sample(rep((1:length(grid))[grid==1],2),1)]=0
      }else{ grue[sample(1:(np*mp),np+mp)]=1}
     if (bez>jbo){ bez=jbo;sprk=grue}
     if (log(runif(1))<(obj-jbo)/temp){

leading to

>  dumban(grid,T=1e6,temp=100,beta=.9999)
[1] 8
     [,1] [,2] [,3] [,4] [,5]
[1,]    0    1    0    1    0
[2,]    0    1    0    1    0
[3,]    0    1    0    1    0
[4,]    0    1    0    1    0

which sounds like a potential winner.

Hamiltonian tails

Posted in Books, Kids, R, Statistics, University life with tags , , , , , , on July 17, 2018 by xi'an

“We demonstrate HMC’s sensitivity to these parameters by sampling from a bivariate Gaussian with correlation coefficient 0.99. We consider three settings (ε,L) = {(0.16; 40); (0.16; 50); (0.15; 50)}” Ziyu Wang, Shakir Mohamed, and Nando De Freitas. 2013

In an experiment with my PhD student Changye Wu (who wrote all R codes used below), we looked back at a strange feature in an 2013 ICML paper by Wang, Mohamed, and De Freitas. Namely, a rather poor performance of an Hamiltonian Monte Carlo (leapfrog) algorithm on a two-dimensional strongly correlated Gaussian target, for very specific values of the parameters (ε,L) of the algorithm.

The Gaussian target associated with this sample stands right in the middle of the two clouds, as identified by Wang et al. And the leapfrog integration path for (ε,L)=(0.15,50)

keeps jumping between the two ridges (or tails) , with no stop in the middle. Changing ever so slightly (ε,L) to (ε,L)=(0.16,40) does not modify the path very much

but the HMC output is quite different since the cloud then sits right on top of the target

with no clear explanation except for a sort of periodicity in the leapfrog sequence associated with the velocity generated at the start of the code. Looking at the Hamiltonian values for (ε,L)=(0.15,50)

and for (ε,L)=(0.16,40)

does not help, except to point at a sequence located far in the tails of this Hamiltonian, surprisingly varying when supposed to be constant. At first, we thought the large value of ε was to blame but much smaller values still return poor convergence performances. As below for (ε,L)=(0.01,450)

la finale

Posted in Kids, pictures, Travel with tags , , , , , , , , on July 16, 2018 by xi'an

A very pleasant stroll through central Paris this afternoon, during “la” finale, when France was playing Croatia. Bars were all overflowing onto the pavements and sometimes the streets, each action was echoed throughout town, and we certainly did not miss any goal, even from the heart of the Luxembourg gardens! Which were deserted except for the occasional tourist, just as the main thoroughfares, except for police cars and emergency vehicles. Since the game ended, horns have been honking almost nonstop, even in the quietest suburbs.