Evolutionary Prisoner’s Dilemma sim

This is a small programming project I worked on in 2013-2014.  Although I wrote a blog series about it at the time, this is not a repost of that series.  Instead, this is a repost of the explanation I wrote earlier this year, when I uploaded the project to github.  If you liked this article, you might also enjoy this interactive game, although I had nothing to do with that one.

The Prisoner’s Dilemma is an important concept in game theory, which captures the problem of altruism. Each of the two players chooses to either cooperate or defect. Cooperating incurs a personal cost, but benefits the other player. If both players cooperate, then they are better off than if they had both defected. In a single Prisoner’s Dilemma, it seems that it’s best to defect. However, if there are multiple games played in succession, it’s possible for players to punish defectors in subsequent games. When multiple games are played in succession, it is called the Iterated Prisoner’s Dilemma (IPD).

The best approach to the IPD is highly nontrivial. In 2012, William Press and Freeman Dyson proved that there is a class of “zero-determinant” strategies that seem dominant, and which would lead to mostly defection. However, Christoph Adami and Arend Hintze showed that the zero-determinant strategies are not dominant in the context of evolution. Understanding this issue could elucidate why humans and other creatures appear to be altruistic.

How the simulation works

  1. We have a population of 40 individuals. Each individual has 4 parameters that govern how they play IPD.
  2. Each individual plays IPD against 2 other individuals in the population, and their fitness is calculated from their average score.
  3. One individual dies, and another reproduces. The probability of reproduction increases with fitness, and the probability of death decreases with fitness.
  4. All the parameters of the individuals are mutated by small amounts.
  5. Steps 2-4 are repeated a million times. Each repetition is called a “generation”.

[Read more…]

A toy model of media economics

One thing I’m interested in is the theoretical economics of entertainment media. For instance, we know that people have a wide variety of tastes in movies, but movie producers aren’t necessarily interested in catering to everyone’s tastes, they’re just interested in maximizing profit. You can imagine situations where this would lead most movie producers to cater to the most popular tastes, and to ignore fringe tastes.

Economists would describe this system as a kind of monopolistic competition. The problem is, monopolistic competition is super complicated and dependent on details, and I for one don’t understand it. So in order to better understand monopolistic competition, I want to build a toy model–the very simplest model that vaguely resembles monopolistic competition. The goal is not to build a realistic model, it’s more of a conversation piece.

Disclaimer: I have no education in economics, I’m more of a game theory guy.

Movies, democracies, and food trucks

Monopolistic competition is a system where different firms produce goods that are differentiated from each other. To make the very simplest model, we’re going to imagine that goods are differentiated from each other along only a single axis. For example, suppose that each movie falls along a one-dimensional spectrum from “drama” to “comedy”. And where a movie falls along this spectrum is the only thing that could differentiate it from other movies. Some viewers prefer comedies, and some prefer dramas, and some prefer dramedies.

[Read more…]

I tried microtonal music and liked it

The pitch of a note is determined by its frequency, and frequency can vary within a continuous spectrum. And yet, in the western music tradition, we only use frequencies with discrete values. That’s not a bad thing, but it implies a whole world of possibilities not explored. Microtonal music, also known as xenharmonic music, sets out to make use of the unused frequencies.

I recently tried listening to a lot of microtonal music, because I discovered that you can find lots of it through the microtonal tag on Bandcamp. Sure, a lot of it isn’t very good because anyone can put music on Bandcamp, but there were enough gems that I continued to peruse the tag. I’ll share just two examples. First, I selected Brendan Byrnes, because I think his music has the most pop appeal, while also being unapologetically microtonal.

[Read more…]

An altruistic Prisoner’s Dilemma

This is a repost of an article I wrote in 2015, with a short postscript added.

Jeff Kaufman talks about an ethics trade that he sometimes does with a friend.

I have a friend who is vegan for animal welfare reasons: they don’t think animals should be raised for food or otherwise suffer for our benefit. On the other hand, they used to really enjoy eating cheese and miss it a lot now that they’re vegan. So we’ve started trading: sometimes I pass up meat I otherwise would have eaten, and in exchange they can have some cheese.

This is a win-win for the vegan, since they get to have some cheese, and there is no net harm to animal welfare.  It is not clear what’s in it for Jeff though, except for his idiosyncratic preference to have such trades.  I am not sure this is an interesting scenario by itself, since, in general, any trade is possible with sufficiently idiosyncratic preferences.

Therefore, I propose a similar scenario, which I’ll call the vegan/omnivore dilemma.

[Read more…]

Tessellation symmetry

This is (the last) part of my series about symmetry in origami.

A tessellation is a set of tiles that fill up a 2D plane. And I do mean the entire 2D plane, infinite in extent. When we talk about origami tessellations, these are models that could hypothetically fill a 2D plane, if we had an infinite amount of paper. In practice, an origami tessellation is finite, but for the purposes of discussing symmetry, we will imagine them to be infinite.

example origami tessellation

An example of an origami tessellation, the Rectangular Woven Design by David Huffman

Previously, I only discussed two kinds of symmetry transformations: rotation, and reflection. However, many tessellations have repeating patterns, and this in itself is another form of symmetry. Are there other kinds of symmetries that we forgot? Let’s take an inventory of all the possible kinds of symmetry transformations.

[Read more…]

Symmetrical coloring theorem

This is an appendix to my series about symmetry in origami. Here I will provide a proof that my construction of symmetrical colorings works.

While I try to make the series accessible to people who do not know much about math, I don’t think there’s much point in trying to make this proof broadly accessible. This is intended as a reference for people with some experience with group theory. (You need to know about cosets at the very least.)

[Read more…]

One: the universe’s favorite digit

This is a repost of an article I wrote way back in 2011.  I’m still proud of figuring this one out.

Out of all the digits, from zero to nine, one is the most common.  This has to do with the log scale.

The log scale captures an important fact that is true of many quantities in life.  Take money for instance.  If you have one dollar, then earning another dollar is great because you’ve doubled your money!  If you have a million dollars, earning another dollar does not make much of a difference.  Small changes matter less the more you already have.

This is true on a log scale too.  On a log scale, 1 is the same distance from 2 as 100 is from 200.  The higher you go up, the more the numbers all get smooshed together.  What does that mean for the digits from zero to nine?

A picture of a log scale, highlighting the regions that have 1 as their first digit (eg 1-2 and 10-20)

In the above picture, I show a log scale.  And on that scale, I highlighted in blue all the regions where 1 is the first digit of the number.  You should see that the blue regions cover more than one tenth of the log scale.  In fact, they cover about 30%.  And so, if we pick numbers randomly on the log scale, about 30% of those numbers will have 1 as their first digit.

Just for fun, let’s apply this concept on the fundamental constants of nature.  I will compare two hypotheses: [Read more…]