Chutes and Ladders Infinite Loop

I play Chutes and Ladders with my kids sometimes. It isn’t a game of skill. Many months ago I was involved in a game that went on and on and on. As soon as someone would get close to the end he or she would land on a chute and be shunted nearly back to start.

I was left wondering just how long a game would last. So this week my son and I implemented a simulator in Python to calculate how long any one person’s game would last. Each person’s play is independent in Chutes and Ladders, the characters do not interact. Therefore, simulating an entire game is almost as easy as simulating a single player’s experience.

First, the board is 100 cells long and the spinner gives you a value between 1 and 6, just like rolling a die. A fair die will have an average roll of 3.5, so on average it would take about 100/3.5 = 28.6 turns to finish a game if there were no chutes or ladders. The histogram of game length without chutes and ladders is below. The longest plausible game is about 35 turns in this scenario and the average is 28.6 turns, estimated from 10,000 random trials.

chuteshist_nochutes

The addition of chutes and ladders stretches the histogram radically. Instead of the longest single-person game being about 35 turns, it is now over 200 turns. Fortunately, a 200-turn game is not very likely. Surprisingly the average is not a hundred million years. At 30.8 turns the average game with chutes and ladders is only a little longer than the average game without.

chuteshist

Pretty cool.

 
import random 
import pylab as plt
import numpy as np
d = {}
for i in range(1, 101):
    d[i] = i

cl = {1: 38,
     4: 14,
     9: 31,
     16: 6,
     21: 42,
     28: 84,
     36: 44,
     48: 26,
     49: 11,
     51: 67,
     56: 53,
     62: 19,
     64: 60,
     71: 91,
     80: 100,
     87: 24,
     93: 73,
     95: 75,
     98: 78}
d.update(cl)
numturnsa = []
for t in range(10000):
    numturns = 0
    pos = 0

    while True:
        numturns += 1
        pos += random.randint(1,7)
        if pos > 100:
            break
        # To "play" without chutes and ladders, comment out the next line.
        pos = d[pos]
    numturnsa.append(numturns)

plt.figure(figsize=(5,3))
plt.subplots_adjust( .13, .15, .95, .97)
plt.hist(numturnsa, 60)
plt.xlabel("Number of turns")
plt.ylabel("Count")
plt.savefig("chuteshist_nochutes.png", dpi=200)
numturnsa = np.array(numturnsa, dtype="f")
print "The average number of turns is",np.mean(numturnsa)

Monsoon

In the desert it almost never rains. I know, you know. When I lived in upstate New York, in my foolish youth, I bought a motorcycle in the beginning of April. I was anxious to learn to ride. Too bad, because it rained every day for an entire month. Now I live in New Mexico. Two years ago we had not one drop between the end of December and July.

Where you live the weather turns with a unique step. Here, the summer breaks in July when the monsoon comes. Moist air from the Gulf of California and the Gulf of Mexico flow north over the state and give rise to afternoon thunderstorms. It is the most beautiful weather of the year here. The clouds rise miles—literally—into the sky and continuously billow in fractal glory.

Last week I configured my Raspberry Pi computer with its PiCam to take time-lapse video out my back window. The view is to the east over the Sandia Mountains. I took pictures about every six seconds from 10:30 am until dark, around 8:30 pm. The whole day compressed into four and a half minutes. The best video was from July 14, others are below.

It is hard to understand the desert if you have never lived in one. In the picture below you can see what it would be like if Leeds were in Albuquerque. A nation that ruled the world for a few hundred years fits comfortably in the desert southwest.composite

The rest of the videos I created are here, with the most interesting at the top.

July 11

July 13

July 8

July 7

July 10

July 16

July 15

The Spiraling Shape

The Spiraling Shape will make you go insane
Everyone wants to see that groovy thing

–They Might Be Giants

The chambered nautilus is sometimes called a living fossil. It is the closest living relative of the ammonoids, and cross sections of its shell are familiar to every adult in the western world. Most kinds of ammonoids lived a long time ago. They started appearing in our Devonian strata around 415 million years ago. Pretty cool, since modern humans have been around 0.195 million years. If you consider the chambered nautilus close enough, then you might say that these critters have been around 2000 times longer than humans. That is real staying power.

In June my wife and I visited San Francisco for a vacation. A delightful city for touring because it has such a mix of old turn of the 20th century buildings, awesome bridges, a cool sea breeze, great parks and museums, shopping, cultural diversity, and enough hipsters to feed Cthulhu for an eon. Unless someone can find a more suitable use for hipsters.

In Chinatown we saw all the usual junk. But there was also a rock shop that had a nice assortment of cross-sectioned fossil ammonoids or nautiloids. I dug through and looked for one with the most open inner spirals. And here it is.

Nauty

I scanned it at absurdly high resolution, the largest diameter is 1.6 inches. The construction of the nautiloid is fascinating. The spiral is logarithmic, as you can find asserted all over the web. Of course, in my entire life I have never seen anyone actually measure the spiral and show its logarthmic nature. But it looks like it a logarithmic spiral.

The structure is self-similar. It is hard to tell how big this little shell is because it would like basically the same to your eye at ten times the size. I love that: fractal without fragmentation.  The creature, I suppose, could grow large just by repeating the same basic step—grow a new chamber. The genetic code to scale up must have been quite an innovation, evolutionarily speaking.

g_apng

Distilling the spiral of the shell to its simplest shape shows awesome, but not perfect, consistency.

g_b

I have never seen a discussion of how the maximum and minimum buoyancy of the creature might have changed as it grew. You can bet that there is a clever relationship between the mass of the cephalopod’s body, the mass of its shell, and the volume of each successive  chamber, at least for those that can move vertically. Seafloor-dwelling species might be marked by a faster-opening spiral that keeps their shell from rising. Why is that a safe bet?

I understand that the nautilus spends the day deep in the ocean, and rises near the surface to hunt at night. They control their depth by pumping water in and out of their shell chambers. A nautilus’ chambers are connected by a little hole, and I can’t see any holes between chambers in my fossil so maybe mine wandered about on the seafloor or floated at a constant depth.

I measured my trace for the distance between spirals. I divided them all by the smallest one and produced the measurements

1 1.3 2.9 5.6 12 25 49
g_c
And this spiral does indeed show logarithmic growth. The plot shows the plot of the natural logarithm of the same measurements. Its consistency is so very, very good. I suppose that’s what makes the shell so pretty.
plot
 

Ear Tips for Noise Canceling Headphones

Most people have never tried in-ear headphones. They get ear wax on them, so to don’t share well. Wearing them on stage, musicians can hear their own instruments without going deaf. Since musicians use them for performance in-ear headphones are also called monitors, just like the speakers that point toward the band from the front of the stage.

Distraction, from airplane noise, office noise, maybe your own keyboard, annoys. Three headphones solve the problem. Most famously, Bose’s active noise canceling Quiet Comfort line and similar products by other makers. Passive noise reduction from sealed over-ear headphones is about 10 dB. In-ear monitors offer passive isolation between 20 and 30 dB.

I demoed the Bose phones years ago, and they hissed with the noise cancellation on. The sound quality was neither exceptional nor awful, but was poor for a $300 price. World-class sound quality is available from makers like Etymotic and Westone with in-ear monitors that provide as much isolation as active noise canceling models.

But in-ear monitors have one major drawback, they go in your ear canal. That means that they can get gross with ear wax, can be painful or itchy, and they can wear out. In my nine years using in-ear monitors I only ever found the foam tips from the manufacturer comfortable. The three-flange silicon tips isolate amazingly, but itch like fire after twenty minutes and hurt like a drill after sixty. The foam tips are comfortable, almost as isolating as the three-flange tips, but cannot be fully cleaned and wear out after three months.

tip_catalog

The most recent time I wore out a pair of foam tips, I decided it was time to look at the alternatives. I hoped to find, ideally, a comfortable silicon tip with the isolation of the foam tips or an inexpensively replaceable foam tip. It seems to be sort of a niche market, and I failed to find any useful comparisons on the web. So, I did my own.

I purchased a sizing kit from Westone, another from Monster, and a pack of the universally-liked Comply foam tips. Testing included a few leftover tips from the headphone’s original purchase, and I included those in the comparison.

I evaluated each tip for fit, seal, pain, itching, sound quality, isolation, and microphonics. Fit, seal, sound quality, and isolation are all related. With in-ear phones a poor seal means poor isolation and poor bass response and poor sound quality. Good fit depends on having the correct size tip for your ear. Medium tips from most manufacturers fit my ears well. The calipers in the picture below show a base diameter around 0.465 in (1.18 cm).

comply-tip-size

Most of the tip designs are old. Grubby among my grandfather’s shooting supplies, foam and triple flange tips were familiar to me twenty-five years ago. Recently Westone introduced a single-flange tip focusing on good seal and comfort. These, along with other single-flange tips, suffer from awful microphonics. When cables rub against anything, like your arm as you move the mouse, the motion travels along the cables and makes loud popping noises. Single-flange tips have the worst microphonics.

The best overall tips for me are Comply’s T-100 PLT medium foam tip. They cause no pain or itching, seal great and offer very good isolation, have low microphonics, and sound very good. Like all foam tips, they will wear out in three months and get waxy and gross. And they are neither the most isolating nor the quietest.

The best sounding tips are the Westone silicone three-flange tips, which offer by far the best isolation and by a small margin the best sound. After twenty minutes they also offer crushing pain and infernal itching. The three-flange tips have a place in my kit, but I don’t use them long.

Westone’s single flange tips are silicone, and are comfortable. My notes describe the itching from Westone’s silicone three-flange tip as extreme. After that, finding any silicone tip bearable was a surprise. The Westone Star tip is comfortable. It has poor microphonics, and poor isolation; it has no place on an airplane or a noisy office. On the other hand, Star Tips are cleanable and provide some isolation, so they are candidates for the gym. These also have a place in my kit.

The rest of the tips are unsurprising. Everything from Monster had poor isolation and had distracting microphonics due to a poor design. All of the other fitting foam tips are acceptable, but none are as good as Comply’s. All the other silicone tips are unacceptable for me, too painful, too itchy, too microphonic, and sound too poor. The results for all tips that fit reasonably well are in the table at the end.

I tested these tips with an hour-long playlist from mixed genre, seven songs in all. It starts with D. Barenboim/Berliner Staatskapelle recording of Beethoven’s Symphony 9, included to show dynamic range of symphonic instrumentation. The next two songs have typical mid-pitch-heavy pop songs including Adele’s One and Only off her album 21, and Erica Badu’s Four Leaf Clover from Baduism. Next, Erica Badu’s Rimshot shows the performance with an extreme deep bass opening line. Sweet Jane from the Cowboy Junkies is more typical pop. A mid-heavy but delicate sound and detailed sound from Miloš Karadaglić’s album Mediterráneo with his performance of Granados’ Danzas españolas, Op.-No. 2 Oriental. Finally, a very detailed song from Rush, The Necromancer off their album Caress of Steel has shown the weaknesses of many sound systems. I chose an hour-long playlist because in my experience in-ear monitors often lead to such itching and pain in the ears that I want to claw them out of ears screaming after forty minutes.

Monster produced the only foam tips I avoid. To fit my earphones you put the tiny red rubber rings around the earphone and then slide the tip over the top. The result was poor isolation and poor microphonics.

monster-tip

Tip

Size

Fit

Seal

Sound

Iso.

Mic.

Pain

Itch

Westone Classic Foam

Med

G

G

G

G

G

G

G

Westone Silicone White 3-flange

G

E

E

E

G

M

VP

Comply Foam T-100 PLT

Med

G

G

VG

VG

VG

VG

VG

Westone Star Silicone Black 1-flange

Med

G

G

VG

P

P

VG

VG

Westone Classic Foam

Med-Long

G

G

G

G

G

VG

G

Westone Truefit+ Foam

Med

G

G

G

G

G

G

VG

Westone Silicone Black 1-flange

Med

G

G

G

G

P

G

G

Westone Star Silicon Black 1-flange

Med-Long

G

G

VG

P

P

P

G

Weston Truefit+ Foam

Med-Long

G

VG

G

VG

G

G

G

Westone Silicone Clear 1-flange

Med

G

P

P

P

P

P

G

Westone Classic Foam

Small-Long

G

P

P

P

G

VG

G

Monster Foam

Med

G

G

G

P

P

G

G

My wife put me onto Bloglovin for those who follow with an aggregator. If you like, Follow my blog with Bloglovin. Finally, I have had no contact with the makers of these products, and I wasn’t compensated or paid in any way. Quite the contrary, I bought all the equipment reviewed here.

Some Curious Micrographs

We have an old microscope and a camera adapter for it. Occasionally we dig it out, and light some small stuff up. Several weeks ago my son’s science workbook had a multiple choice question, roughly “which of these would look different under a microscope”

  • salt in water
  • sugar in water
  • pollen in water

An experiment seemed in order. After exploring those boring solutions we explored other things. The first is the tip of a technical pen. I believe the narrow diameter part is the wire, and the large diameter is the tube. I suppose the fillet is a meniscus of ink.

Rotring Technical Pen Tip

20140207-23

The feather is cool enough to look at, but within the feather is a single fiber from a blue yarn that my wife was crocheting with.

A Feather and a Colored Thread

20140207-30

At the request of my son, I plucked one of my precious head hairs. I had hoped to see the surface structure of the hair, a tiny scaled surface. It is visible, but not clearly. Still, pretty cool.

A Hair at the Root

20140207-14

We looked at paper, too. But paper was not that interesting until we compared three different types. Notebook paper, a Kleenex, and slice of technical drawing paper (like vellum). The difference between the fibers is amazing.

A Tissue and a Strip of Technical Drawing Paper

20140207-10

My son wanted to look at candle wax too, but the toothpick we used to get it is far more interesting.

Toothpick with Candle Wax

20140207-19

You think that milk has been homogenized and so it should look like a smooth, uniform material. I was fascinated to observe a sandy or granular structure under an optical microscope. The microscope cannot really resolve the individual particles, but it can show that the particles are there.

Milk

20140207-24

The final picture is shows the microchip inside a slow-fade RGB LED. This LED fades through the gamut of colors, and macroscopically looks identical to any other LED. The picture is blurry because it is imaged through the acrylic body of the LED. Nevertheless, the microchip structure is visible. At the bottom you can see four solder joints, one for ground (or Vcc) and red, green, and blue components.

Microchip Inside a Slow-fade LED

20140207-29

Typefaces

Updated February 5, 2014 to correctly display the LaTeX screenshot, minor prose edits, and added discussion of font styles.

I do not know if you have a favorite font. I do. I really like Microsoft’s Calibri font because it is very readable on screen and paper and it looks professional. With that in mind, it has several huge shortcomings for much work. Let me list

  • You don’t have a right to use the font unless you have purchased it (for $120) or acquired with a legal license of a Microsoft product that includes it.
  • Calibri does not have small caps family member
  • Calibri does not have a corresponding math font

Many people, including me, got to know Calibri because it is the default font in Microsoft Word. I am trying to find a way to leave Word because it has poor support for equation numbering, mediocre bibliography support. It is also difficult to automate updated graphics using non-Microsoft work flow. For example, I often generate graphics in Python with Matplotlib and write them to a file. I would like my document workflow to pick up the picture automatically when it changes but have not found a reliable way to do this in Word.

Microsoft Word is fundamentally poor at rendering documents compared to a display tool like Adobe Reader. Consider the following screenshot comparing a default Word document snippet in Calibri with Word’s rendering of text in the TeX Gyre Bonum OpenType font. Next screenshot is from a Word display at 100% zoom.

word_example

The shading in the Bonum section is appalling. Look at the dot over the letter i in pi. Word renders the compatible TeX Gyre Bonum Math and TeX Gyre Bonum fonts differently depending on whether it is in equation mode or body text. The shading in the top paragraph is good; however, the overall construction is horrible. In Word a number in equation mode is displayed in the default math font Cambria. Calibri does not match Cambria and the two numbers can’t look the same. Furthermore, the fraction in the middle of the paragraph causes the line spacing to expand just on that line, making it look almost like there are more paragraph breaks than there should be. Distracting and unattractive.

The next picture is screenshot from Adobe Reader X at 100% zoom viewing a LuaLaTeX generated LaTeX document.latex_example

First, the TeX Gyre Bonum snippet is readable and reasonably good looking. The math font and text font are indistinguishable, as they should be. LaTeX handles even Microsoft’s pet font Calibri better than Microsoft. The fraction renders clearly and readably. It does so without creating a large horizontal gap.

The ideal faces, from my point of view, should:

  • Be embeddable in your electronic documents
  • Not cost much to install on every system you want to use (eleven computers at least)
  • Work on Windows, Linux, and MacOS
  • Include regular, bold, italic, bold italic, small caps, and math families
  • Be functional with Word or other non-LaTeX tools.

The license problem is unquestionably the most limiting factor since OpenType now seems to allow fonts to work across platforms. The GUST project has created a series of libre fonts called the TeX Gyre fonts. Among these fonts, only three have the math family, and all three of these satisfy the other requirements.

TeX Gyre Bonum Based on URW Bookman L
TeX Gyre Pagella Palatino-like
TeX Gyre Termes Times-like

There are several other Gyre fonts that are quite attractive and potentially useful but lack the math fonts. TeX Gyre Schola seems to be planning a math font which is not yet ready. If you don’t need to have a math font, or don’t need a matching math font then there are many other fonts to consider. Fontsquirrel has a lovely list of libre fonts. There are other fonts available for LaTeX that can produce good results but do not seem to have a functional method to work with other tools.

Wikipedia describes Calibri as a “humanist sans-serif typeface”. The closest TeX font with math support, to my eyes, is KP Sans-Serif. The strokes are not as modulated so the KP looks less refined than Calibri. I do not see how to use that typeface outside of LaTeX. If you are interested in other LaTeX fonts, consider looking at the LaTeX font project fonts with math support.

In Youth and Beauty

I bought two pieces of art to hang from my son’s elementary school. I loved them immediately. The abstract tiles where done by my son’s 3rd and 4th grade class. The tree was made by a 1st and 2nd grade class. Both pieces of art are really lovely. The tree has a cool property, like a scene in Ferris Bueller. The art changes its character from far away to as close anyone would care to get. First, the tiles of abstract images of persons and animals was made under the rule that the student not pick up the pen during the drawing and then there are rules for filling with color, like a graph coloring rule.

20131230-05

The other artwork is a sort of mosaic of paper circles colored and glued to a black foam core board. The tree shots zoom in with three steps doubling the zoom at each step.

01-20131224-Tree

 

02-20131224-Tree-inset03-20131224-167

 

04-20131224-167-inset05-20131224-168

 

06-20131224-169-inset07-20131224-171