Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Choose Language Hide Translation Bar
Community Manager Community Manager
JMP, Three Ways

This blog post was written by a blogger who is no longer at SAS


My friends and co-workers know me as quite the little francophone. I travel to France as often as I can. I'm currently working on a master's degree on the subject at North Carolina State University. And I hoard every French newspaper and magazine that I get my hands on.


Le Figaro is a daily paper that adds a supplement, Le Figaro Magazine to its Saturday edition. There you find art news, columnists, and my favorite: games.


I'm consistently amazed at how the French make games simply out of things we consider dramatically un-fun. For example, one the games in the magazine relates to a letter from Blaise Pascal to his brother, where you have to (a) complete the letter with 16 given words; (b) correct 16 spelling or language errors; and (c) find 15 anomalies, anachronisms, or historical impossibilities.


One of the number games jumped out at me (pun intended). Here's the game I'm going to solve using JMP, in its original form.









[Find the value of a ball of each color, knowing that the total of the balls on a line is always equal to 12]


There are at least three ways to solve this-- probably more, if I thought about these things longer than it took me to eat a Happy Meal™ at Chez McDo's.



Method 1: Brute Force



A very brute-force approach is to loop through all the possible colors (red = x, brown = y, black = z. blue = w) recognizing that they can't be less than zero nor more than 12. Here's a JMP script that does that : Four For loops that cycle each value from 0 to 12 in steps of 0.5. When it hits a result, it writes the result to the log.


For( x = 1, x <= 12, x += 0.5, 
	For( y = 1, y <= 12, y += 0.5, 
		For( z = 1, z <= 12, z += 0.5, 
			For( w = 1, w <= 12, w += 0.5, 
				If( 2 * z + 2 * w == 12, 
					If( z + 2 * y + w == 12, 
						If( 3 * y + 2 * x == 12, 
							If( z + y + 4 * w == 12, 
								If( z + w + 4 * x == 12, 
									Show( x, y, z, w );

The results? red = 1.5, brown = 3, black = 5. blue = 1

Method 2: Least-Squares

The next way is to recognize this as a least-squares problem. The value attached to the balls are the coefficients of a linear model, with the balls themselves serving as the data. So, I can make a JMP Data Table that holds the five rows and information on the four colored balls. To wit:




And using JMP's Fit Model window, I can get least-squares estimates on the balls. I'm using a no-intercept model because I know that the linear model should go through the origin.






Like that ("Bam!," I say to myself), I get the results and the answer to the puzzle.




Method 3. Using Math


If you took Algebra II in the past 40 years, you studied these things called matrices. Turns out they're actually useful. And if you don't recognize the puzzle in its least-squares sense, there's always this mathematical way of looking at it. Don't tell anyone, but they're actually the same approach: The math you see below is what's going on behind the scenes in JMP.


If you express the puzzle set-up using matrices (five rows representing the five rows of the puzzle), you can have the table itself represented like this (call it A).


A = [0 0 2 2
     0 2 1 1
     2 3 0 0
     0 1 1 4
     4 0 1 1]

and the fact that these five conditions all sum to 12, represented as


C = [12


with a final matrix b representing the unknowns : the value of the balls.


b = [x


To solve this, we simply have to start with


   Ab = C


and get b alone on the left side of the equation. Typically, we'd do the simple thing of multiplying both sides by A-1, like this:


   A-1Ab = A-1C


But don't you know there's a problem. Since the puzzle has four variables and five rows, its matrix representation isn't square. So we can't just use an ordinary inverse. We can multiply A by its transpose to get a square matrix, although this still isn't invertible. Luckily, JMP has the Moore-Penrose Generalized Inverse function (which sounds better in italics, don't you think?). Using it, I can write a simple JMP script to assign the matrices and solve the problem:



A = [ 0 0 2 2, 0 2 1 1, 2 3 0 0, 0 1 1 4, 4 0 1 1];

C = [12, 12, 12, 12, 12];




giving the result (with rounding error, I suppose in the delicate inversion process)


[1.5, 3, 5.00000000000001, 0.999999999999994]

The same answer. And if the rounding errors give you the heeby-jeebys, you can use JMP's Solve function instead.



A = [ 0 0 2 2, 0 2 1 1, 2 3 0 0, 0 1 1 4, 4 0 1 1];

C = [12, 12, 12, 12, 12];



Article Labels

    There are no labels assigned to this post.

Article Tags
1 Comment

François Bergeret wrote:

Fourth way to the boulier game

Hi Lee,

JMP has a very nice feature, the desirability functions, that can also be used to solve the boulier issue.

- Creating a dataset with 4 new columns, one per color, with random data from a normal distribution: Random Normal() * 3

- Creating 5 new variables y, one per line, y1 to y5, with a formula to link the colors with the line total (e.g. y1=5black+5blue...)

- Creating 100 000 lines with random data for colors and y1 to y5 results

- Fitting a model for y1 to y5, with colors as explanatory variables

- Emphasis in Fit model platform is effect screening, then set desirability to a target of 12 for each y (desirability=1 when y=12, going to 0 when y is far from 12)

- Convergence tolerance in Maximization options is set to 1E-12 to get exact numerical results for the boulier issue (just a few ms longer)

- Maximizing desirability gives: black=5, blue=1, brown=3, red=1.5

Dataset available on demand

François Bergeret (from France)