Non-Transitive Dice

A couple of weeks ago, there was a general Spring cleaning at my workplace. In the pile of rubble waiting to be moved to the garbage dumpster, I saw a small container with 4 dice. I was intrigued.

It turns out the four dice were special dice called non-transitive dice.

The first die is red and has four sides with 2s and two sides with 6s. The second die is green and has three sides with 5s and three sides with 1s. The third die is purple and has four sides with 4s and two sides with 0s. The fourth die is yellow and has all six sides with 3s.


So, if you roll the red die and then the green die, there are four possible outcomes:

6-5 with probability = (2/6)(3/6) = 6/36 (red wins)
6-1 with probability = (2/6)(3/6) = 6/36 (red wins)
2-5 with probability = (4/6)(3/6) = 12/36 (green wins)
2-1 with probability = (4/6)(3/6) = 12/36 (red wins)

So red will beat green with probability 6/36 + 6/36 + 12/36 = 24/36 = 2/3. In other words, red is much better than green.

If you roll the green die and then the purple die there are four possible outcomes:

5-4 with probability = (3/6)(4/6) = 12/36 (green wins)
5-0 with probability = (3/6)(2/6) = 6/36 (green wins)
1-4 with probability = (3/6)(4/6) = 12/36 (purple wins)
1-0 with probability = (3/6)(2/6) = 6/63 (green wins)

So green beats purple with probability 24/36 = 2/3. Green is much better than purple.

If you roll the purple die and then the yellow die the two possible outcomes are:

4-3 with probability (4/6)(6/6) = 24/36 (purple wins)
0-3 with probability (2/6)(6/6) = 12/36 (yellow wins)

So purple is much better than yellow.

At this point, red beats green. Green beats purple. And purple beats yellow. You’d logically conclude that the red die must be much, much better than the yellow die. But if you roll the yellow die and then the red die:

3-2 with probability (6/6)(4/6) = 24/36 (yellow wins)
3-6 with probability (6/6)(2/6) = 12/36 (red wins)

In other words, yellow is much better than red!

This leads to a nice bar bet game. You let your friend pick any of the four non-transitive dice. Then no matter what die your friend picks, you can always select a better die. If you play several times, you’ll almost certainly win more times than you lose. Very cool practical application of math.

Posted in Machine Learning, Miscellaneous | Leave a comment

Two Software Developer Conferences in September and October 2015

In my opinion there are four really good conferences each year for software developers and IT people who use Microsoft Technologies. Two of these conferences are scheduled for September and October of 2015.

The IT/Dev Connections conference will run from September 14-17, in Las Vegas (at the Aria Hotel). The DevIntersection conference will run from October 26-29, also in Las Vegas (at the MGM Grand Hotel).

See for IT/Dev Connections.

See for DevIntersection.

I have spoken at both events in the past, and I’ll be speaking at both events in 2015. I can strongly recommend both conferences. As a speaker, my reputation depends to some extent on the quality of the events I speak at, so if I didn’t think Dev Connections and DevIntersection were good events, I wouldn’t associate myself with them.


The IT/Dev Intersection event has been running since 2001. Attendance has varied over the years (conferences are highly influenced by the general state of the economy) but I expect somewhere around 2,000 attendees in 2015. The IT/Dev Intersection conference is run by Penton Media. There should be about 250 sessions covering all aspects of development and IT using Microsoft technologies.


The DevConnections event was started in 2012. It was created by people who used to run IT/Dev Intersection. The DevConnections conference will probably have about the same number of attendees (2,000) and sessions (250) as IT/Dev Intersection.

The IT/Dev Connections and DevIntersection conferences are pretty much direct competitors. I wish that one of the two events were clearly superior to the other so I could champion just one, but the reality is (again, in my opinion) that both events are really good.

If you work with Microsoft technologies, check out the two conferences I’ve described, and try to get your company to send you to one (or both!) as a form of training. I think you’ll learn a lot and go back to your work refreshed and energized.

Posted in Conferences | Leave a comment

My Top Ten Favorite Menus

Like many technical people, I’m not really much of a restaurant person. When I eat out I’m usually in my car, talking to a microphone in a clown’s head, and ordering the number 7 combination. With that lack of expertise in mind, here are my top 10 favorite menus I found on the Internet.


1. Tough call, but for the soup, I think I’ll go with the shrimp.


2. Can I have some grilled wife to go with that?


3. This restaurant must cater to a research crowd.


4. Can I substitute simple aggravated assault?


5. What the heck?


6. Does baked backwash call for red wine or white wine?


7. I’d say several of these item names are somewhat curious.


8. Does it come with a flash?


9. Too many wonderful options here.


10. And I’ll have some fungus and pork licer with that flesh.

Posted in Top Ten | Leave a comment

Programmatically Generating Reber Grammar Strings

Reber grammar strings (named after Arthur S. Reber) are strings often used to test if a software system can recognize patterns. Two examples of Reber strings are “BTSXSE” and “BPTTVPXVVE”.

How Reber strings are generated is best explained using a diagram:


The string must start with a ‘B’ (“begin”) symbol. Next can be either a ‘T’ or a ‘P’. If the second symbol is a ‘T”, the third symbol can be an ‘S’ or an ‘X’. The process continues until an ‘E’ (“end”) is reached.

I wanted to programmatically generate Reber strings so I wrote a short C# program to do so. I used the program to find all possible Reber strings that have exactly 8 symbols. I used brute force: I generated 100 million random Reber strings and tracked which of them had exactly 8 characters. There are 7 such strings:


I ran the program looking for Reber strings that have exactly 20 symbols and got 783 strings:

Begin Reber Grammar demo

Found 783 distinct Reber strings with length = 20 symbols
. . .

The program code for the 8-symbol strings is:

using System;
using System.Collections.Generic;

namespace ReberGrammar
  class Program
    static Random rnd = new Random(0);

    static void Main(string[] args)
      Console.WriteLine("\nBegin Reber Grammar demo\n");

      Dictionary<string, bool> dict =
        new Dictionary<string, bool>();

      for (int i = 0; i < 100000000; ++i)
        string reber = Reber();
        if (reber.Length != 8) continue; // only length 8
        if (dict.ContainsKey(reber) == false)
          dict.Add(reber, true);

      Console.WriteLine("Found " + dict.Count +
        " distinct Reber strings");

      int id = 0;
      foreach (string rs in dict.Keys)
        Console.WriteLine(id + " " + rs);


    } // Main

    static string Reber()
      return DoNode0("B");

    static string DoNode0(string curr)
      double p = rnd.NextDouble();
      if (p < 0.5) { return DoNode1(curr + 'T'); }
      else { return DoNode2(curr + 'P'); }

    static string DoNode1(string curr)
      double p = rnd.NextDouble();
      if (p < 0.5) { return DoNode1(curr + 'S'); }
      else { return DoNode3(curr + 'X'); }

    static string DoNode2(string curr)
      double p = rnd.NextDouble();
      if (p < 0.5) { return DoNode2(curr + 'T'); }
      else { return DoNode4(curr + 'V'); }

    static string DoNode3(string curr)
      double p = rnd.NextDouble();
      if (p < 0.5) { return DoNode2(curr + 'X'); }
      else { return DoNode5(curr + 'S'); }

    static string DoNode4(string curr)
      double p = rnd.NextDouble();
      if (p < 0.5) { return DoNode3(curr + 'P'); }
      else { return DoNode5(curr + 'V'); }

    static string DoNode5(string curr)
      return curr + 'E';

  } // Program
} // ns

Reber strings cannot be recognized by regular neural networks, but a special form of NN called a recurrent neural network can learn to recognize Reber strings.

Posted in Machine Learning | 2 Comments

Recap of the 2015 IoT Evolution Conference

I spoke at the IoT Evolution Conference, which ran from August 17-20, in Las Vegas. The conference was all about IoT (“Internet of Things”) topics. See My talk was “Introduction to Swarm Intelligence for IoT”.


I estimate there were about 600 attendees at IoT Evolution. Like most technical conferences, the audience was overwhelmingly male. But unlike many technical conferences, the attendees at IoT Evolution were extremely varied in their job roles — CEOs, sales managers, engineers, business development people, and so on.


The Expo part of the event had representation by big companies (IBM, Cisco, AT&T, Intel, Oracle, etc.) as well as small startup companies and everything in between. I’d say the Expo had about 60 booths.

My impression from IoT Evolution is that people aren’t quite sure exactly what IoT is. The classic example of IoT is placing sensors on all the devices in a home so that those devices can communicate with each other and be more efficient. But, to be honest, I’m not excited by the prospect of my oven talking to my shower. But there are other IoT scenarios that really intrigue me.


It seems as if most of the companies represented at IoT Evolution were there to see what other companies are doing in the IoT space. And that’s not a bad thing. I suspect that companies fear that someone will come up with an IoT killer app, and so they want to stay informed. I’m not so sure there is an IoT killer app, but time will tell.

I had a good time. I learned a lot and came back to work with renewed energy. The event was at Caesars Palace, which isn’t one of my favorite places (a bit overpriced in my opinion), but I’ve been to conferences in far worse venues.

The bottom line is that I thought IoT Evolution was a good use of my time, and I hope to speak there again in 2016. If you’re involved with IoT, I recommend that you investigate the IoT Evolution events (there are several) to see if attending might be useful.

Posted in Conferences | Leave a comment

Neural Network Binary Classification

I wrote an article titled “Neural Network Binary Classification” in the August 2015 issue of Visual Studio Magazine. See

A neural network classifier makes a prediction based on predictor variables. For example, you could predict the political leaning (conservative, moderate, or liberal) of a person based on their age, education level, occupation, and so on. When the variable to predict can be one of only two values, the problem is a special case called binary classification. For example, the problem of predicting the sex (male or female) of a person based on their income, political leaning, and so on is a binary classification problem.


In my article I explain that there are two ways to implement a binary neural network classifier. One approach uses a single output node that always has a value between 0.0 and 1.0. If male is 0 and female is 1, then if the computed output node of the NN is less than 0.5 the prediction is male; if greater than 0.5 the prediction is female.

The other approach for binary neural network classification is to have two output nodes that sum to 1.0. If male is (0,1) and female is (1,0), then suppose the computed output node values are (0.652, 0.348). The computed output values are closer to (1,0) than to (0,1) so the prediction is male.

In my article I discuss the pros and cons of the two implementation approaches. I explain why I prefer the “two-node” technique but why most people prefer the “one-node” technique.

Posted in Machine Learning | Leave a comment

Recap of the 2015 Visual Studio Live Conference in Redmond, Washington

I spoke at the Visual Studio Live Conference, which ran from August 10-14, 2015. There are several VS Live events every year and they’re held at different cities, including Las Vegas, San Francisco, Orlando, New York, and Austin. See The August event was held on the Microsoft campus in Redmond, Washington.


I estimate there were about 350 attendees at the conference. All the attendees I talked to said they were enjoying the event and were learning a lot. The Visual Studio Live conferences have been running for many years, which tells you that the events are well run (poorly run conferences don’t last more than a year or two).

The VS Live Conference sessions covered quite a wide range of technical topics. I was most interested in the talks related to Cloud Computing and Visual Studio. I wasn’t quite as interested in the talks about Web Development and Mobile Development, but some of the talks on those topics were very good.


My talk was “Introduction to R for C# Programmers”. R is a language used to perform statistical analyses. R has been around for decades but interest in R has greatly increased over the past 18 months or so. I explained why developers might want to learn R, showed a “Hello World” of R, compared R and C# (the point being that the two languages are very different), and described alternatives to R.


In my opinion there are four really good conferences for software developers who use Microsoft technologies, one of which is the multiple VS Live events. The Visual Studio Live conferences tend to be smaller than the other three conferences because the other conferences have one large event annually rather than multiple events.

The smaller size of VS Live events encourages more person-to-person communication, which I think is a good thing. If you are a software developer, consider trying to get your company to send you to a VS Live conference — I bet you’ll learn a lot and return to work with renewed energy and enthusiasm. I expect to speak at VS Live Las Vegas in March 2016 — come visit me!

Note: A tip o’ my software developer’s hat goes to all the VS Live organizers, including Danielle Potts and Brent Sutton, and to the event photographer Michelle Cheng, and to the conference technical chairs Brian Randall, Andrew Brust and Rocky Lhotka. All of the VS Live staff are professional, friendly, and just nice people, which contributes to the success of VS Live events.

Posted in Conferences