Latest Posts

Posted by Chris on 24th August 2010

That bell boy problem

Jason at The Number Warrior recently posted about the nefarious bell boy who causes hotel guests to lose a dollar:

Three people check into a hotel. They pay $30 to the manager and go to their room. The manager finds out that the room rate is $25 and gives $5 to the bellboy to return. On the way to the room the bellboy reasons that $5 would be difficult to share among three people so he pockets $2 and gives $1 to each person.

Now each person paid $10 and got back $1. So they paid $9 each, totaling $27. The bellboy has $2, totaling $29.

Where is the remaining dollar?

Here’s my solution, and thoughts.

The quick answer

The answer, of course, is that there is no missing dollar. There can’t be a missing dollar: all of the dollars are accounted for. Without introducing magical leprechaun money or extra-dimensional denominations, there is always $30. So why does it seem like we lost a dollar somewhere?

A note about basis of comparison

One thing that always trips people up is the basis of comparison. In fact, there is a question related to this one that a first seems entirely unrelated:

A man is at his favorite department store when he sees the following sign: “Take an additional 50% off all clearance items marked 50% off.” The man thinks this is a great deal, for 50% + 50% = 100% off; i.e., everything is free! Explain why the man will be sorely disappointed when he gets to the register.

The trouble is that the basis has changed: the first 50% off uses the original cost as a basis, while the second 50% off uses half of the original cost as a basis. Thus the man will actually pay 50% of (50% of 100%) = 25% of the original price. Still a great deal, but not quite free.

Similarly, the “riddle” of the bell boy problem is that the author changes his basis of comparison, but doesn’t change the other values accordingly.

Let’s do the math

This problem is not tricky if we don’t change the basis—if we keep things in terms of the original $30 it is easy to see where all of the money went: $25 to the hotel, for the room, $3 to the three guests as a partial refund, and $2 to the bell boy for his troubles. $25 + $3 + $2 = $30, and no money is missing.

But that’s not how the solution is given. Instead, the problem’s proposed solution incorporates the guests’ refund by arguing that since each person got $1 back, it’s as though they only paid $9 to begin with. But if each only paid $9 to the hotel, then the basis is only $9•3 = $27, not $30.

In other words, we only need to account for $27 under this formulation. Which is quite easy: $25 to the hotel and $2 to the bell boy!

The takeaway

It’s perfectly reasonable to fiddle around with math problems so that they’re easier to understand and work with. When you do this, however, you have to be sure that you don’t change the meaning of the problem.

Posted by Chris on 18th August 2010

How much do bad blackjack strategies affect good players?

The set-up

I don’t play blackjack very often, because it’s not a very inviting game. Mostly, this has to do with the people playing the game, of course. But for some reason, every table I’ve ever sat at was filled with cranky “experts” interested mostly in telling me how I was ruining their game. In roulette or craps, you just put the money down and people have fun. When I learned to play Pai Gow, the whole table was in on the fun, reveling in successes and kvetching over bad beats. In both cases, it is easy to see how one player’s win or loss is independent of another’s. In both cases, other players are happy to let you play any which way you choose, because they know that no matter what you do, you’re only affecting yourself.

Not so at the blackjack table: in blackjack, players have a choice after the hand is dealt to take more cards from the shoe. It is this fundamental difference, this choice that players make hundreds of times an hour while playing blackjack, that turns the blackjack table into an inhospitable wasteland. And so the obvious question to ask is how large an effect do the other players actually have on your individual success or failure at the table on any given night. And the obvious answer is that of course other players affect my game: they’re taking (or not taking) my cards! But the obvious answer is wrong. Other players don’t actually have that great an influence on your winning or losing. The greatest influence on your winning or losing is, in fact, yourself, and your own luck.

Anyone who has played blackjack for more than a few minutes—anyone who has sat at a table and played and lost 10 hands (like myself)—has heard of basic strategy. Fewer of those people have actually taken the time to memorize basic strategy, of course, because gambling is supposed to be fun and risky; it shouldn’t feel like schoolwork! And yet not using basic strategy is the number one way to increase your losses at the blackjack table.

But let’s answer the question at hand. How do other players affect my expected winnings? In the short run—on any given hand, say—it is quite possible for other players to make you lose. They could take an extra card and get a ten. If the dealer has 16, that 10 would have busted the dealer and you would have won, but instead you lost. And that sucks for you, so you look for someone to blame and it might as well be the person who didn’t use basic strategy, who hit when he should have stood.

But in the long run—over a weekend in Vegas, or over all the hands of blackjack you ever play in a casino—other players don’t matter. Even though there may be six other people at the table, your winning or losing depends more on the strategy that you yourself use, and the luck that you yourself have, than on anything those six other people do.

The simulation

Theoretically, we could probably find the answer to this question analytically. Determine the probabilities of everything that happens in a game, factor in all the choices players make, and see what our formulas spit out. But that would be difficult, to put it mildly. So instead, we enlist our friendly neighborhood Python. I wrote a program that plays Blackjack and, crucially, allows players to use different strategies. Then, I told the program to play 10 million hands of blackjack.

To put that into perspective: if you went to the casino every Friday, Saturday and Sunday and played for 10 hours each day, and managed to play 100 hands every hour… it would still take you 64 years to play 10 million hands. In other words, 10 million hands is more than enough to represent your entire lifetime of play. It probably represents multiple lifetimes of play for the average person, actually.

The two graphs below represent 10 million hands played at each of two tables. On the left, all of the players used perfect basic strategy. On the right, only one player used basic strategy, while the other players used a variety of bad strategies—you can read more about those bad strategies below.

Graphs of outcomes at the You should notice at this time that the percentages are, basically, the same. At the perfect table, the player using basic strategy lost 46.33% of the time, won 45.67% of the time, and pushed 8% of the time. At the circus table, on the other hand, the player using basic strategy lost… 46.35% of the time, won 45.65% of the time, and pushed 8% of the time. That’s an extra .02% hands lost, or 2,000 hands in 10,000,000. In case you’re having difficulty visualizing the difference between those percentages, here are the two graphs merged:

Outcomes of 10 million hands at the The details

The simulation used the following rules: dealer stands on soft-17, four decks, double after split, double on any two cards, unlimited resplitting, blackjack pays 3:2.

There were six players at the circus table, using one of four strategies: basic, assume the dealer has a ten hidden, never bust, and play like the dealer. Each of the strategies plays exactly like it sounds. The person assuming the dealer has a ten hidden hits until he busts or his total is higher than the dealer’s shown card plus 10. The person playing never bust strategy always stands if there is the possibility of busting by hitting. The person playing like the dealer stands on soft-17 and hits if his total is less than 17.

All of the strategies that are not basic strategy are very bad. Don’t use them. The important thing is that even though they’re horrendous for the person using them, they don’t affect anybody else in any significant way. Your worst enemy at the blackjack table is yourself, really.

Wins vs. Losses for 4 different strategies

Actual percentages of wins vs. losses for various strategies

The takeaway

If you don’t know basic strategy, and you want to minimize your losses at the blackjack table, you have to learn it. If you do know basic strategy and you notice someone at the table not using it, take comfort in knowing that they’re only hurting themselves.

And feel free to politely offer to help them learn. Don’t be a jerk about it, because that’s no fun for anybody.

Posted by Chris on 7th December 2009

Why Twilight is Bad for Cinema

I’m a little ashamed to admit this in public, but I saw New Moon on opening day. In my defense, it was Ms. PD’s idea. In all sincerity, though, I feel it my duty to encourage you—no, beg, you—not to spend your money on this movie.

Speak

By way of introduction, let’s go back in time to one of Kristen Stewart’s earlier films: Speak. Originally based on a novel, the film tells the story of Melinda Sordino (played by Stewart) as she comes to terms with being raped.

Stewart is very good in this movie, which features very little of her actually speaking to people. She is portraying a character who has retreated almost entirely into her own mind, and her stilted, lifeless delivery portrays Melinda’s pain and confusion brilliantly. Watching Speak, one easily accepts that Kristen Stewart really has experienced the events her character did; that Stewart is truly acting, and making conscious decisions about her portrayal of Melinda.

Thus my willingness, if not excitement, to try Twilight. Here was an actress I was familiar with, and whose work I admired as nuanced and absorbing. I could not have been more mistaken.

The Twilight Saga

The problem with Kristen Stewart’s acting in the Twilight Saga is that she, apparently, isn’t acting. I can’t speak to her personality in the real world, but on the screen, she appears to have just the one delivery: stilted, lifeless, one dimensional and, frequently, grating.

In Speak, her failure to engage the other actors was appropriate for her character. In the Twilight Saga, it only serves to remind the viewer that this is two hours they’re never getting back.

It’s my birthday….

Can I ask for something…?

Kiss me….

A typical exchange, from the trailer.

When Bella cuts her finger on a birthday present, Stewart seems genuinely shocked—not that she managed to cut herself on a box—but that she’s bleeding. It’s as if her character has never experienced, or indeed heard of, a paper cut before. Except that she immediately identifies it as a paper cut, and then proceeds to stare at her finger like she’s never seen it before, while perplexedly delivering, in the same tone as her plea for Edward’s kiss, the following line: Ow…. Paper cut….

One would think that Bella, surrounded by a family of vampires—one of whom is known for his desire to feast on Bella’s blood—would have reacted differently. One would think, actually, that Bella would attempt to put distance between her and the vampire. At the very least, one would think Bella might show some emotion after getting a paper cut (they hurt!). But no, it’s just two short, emotionless, sentence fragments.

Bella as Vessel

Over at The Oatmeal, Bella is described as “an empty shell … that way, any female can slip into it and easily fantasize about being this person.” This probably works well enough in the novel, where the act of reading can itself be a form of creation and where the reader can quite easily imagine being the main character. In my experience, such a thing is at best quite difficult in a film. We do not, in general, go to the movies to become the characters, but rather to witness their existence. The fourth wall of film is that of audience-as-viewer, not audience-as-creator.

It may be that Kristen Stewart’s performance is designed to hide her actual existence—to encourage audience members to pretend that they are Bella. If so, she has failed. What emerges, instead, is a character whose conflicted allegiances are expressed as general stupidity and an inability to process the world she’s become a part of.

Ultimately I don’t think that’s the intention, however. I don’t think the author quite intended for Bella to be so overwhelmed by mythology that she loses her common sense. Indeed, in the first film, Bella is able to research tribal folklore and discover Edward’s true identity. In the hands of a more capable actress, one imagines this intelligence and nuance becoming an enjoyable part of the film’s plot.

The Blind Side

What I really want to talk about though is how movies full of bad acting, bad writing, and bad directing can make so much money, while movies like The Bind Side take in a quarter as much revenue. The Blind Side, which is based on a novel and a true story, does not have to rely on that fact to draw in viewers. It stands on its own as a quality film, written and directed well, with outstanding performances by its actors.

To be certain, it features far fewer teenaged boys walking around shirtless, but if that’s the only reason left to go see the Twilight Saga, one wonders why the bother? There are plenty of shirtless boys on YouTube, MySpace, and Facebook—and they’re free!

Why Twilight is Bad for Cinema

At the end of the day, we must admit that there is a great incentive for Hollywood to produce whatever it is that the American public wants to see. If nobody goes to see a movie, it doesn’t make money, and if it doesn’t make money, then neither do the studios. This means that every theater viewing experience is a vote—not just for that particular movie, but for future movies like it.

By spending almost $500,000,000 to see New Moon in the first three weeks of release, we are telling studios to produce more bad movies like it. For the love of all that is good, please stop rewarding Hollywood for producing bad movies by going in droves to see them.

Posted by Chris on 19th November 2009

Finding Volumes of Cubic Unit Cells

In chemistry, the unit cell of a crystalline solid is the basic building block of that crystal. A crystal lattice is formed by stacking these unit cells three-dimensionally. Perhaps the most basic unit cell is the cubic unit cell—so named because it is, in fact, shaped like a cube. The cubic unit cell comes in three flavors: simple, body-centered, and face-centered.

Finding the volume of a cubic unit cell is easy if you are given l, the edge length: V = l^3. It is also relatively easy if given the density and mass of the element: V = \frac{\text{mass}}{\text{density}}.

What if, however, you are only given the element’s atomic radius? We will use geometry to derive a formula for the volume of a cubic unit cell in each of the three varieties.

Simple Cubic Unit Cells

A simple (sometimes called primitive) cubic unit cell has atoms at each of the eight corners. The locations of the atoms are called lattice points.

A simple cubic unit cell with lattice points marked

Let’s focus on just one of the faces of a polonium unit cell:
One face of a simple cubic unit cell, with Polonium atoms marked

You should note that only part of each atom is drawn in a solid line—this is to indicate that only part of each atom is contained in a given unit cell. For corner lattice points, this portion is 1/8th.

From the picture, we can see that the length of each edge is determined by the radii of two Polonium atoms. Thus l = 2r and V = (2r)^3.

For polonium, whose atomic radius is 168 pm, V = 3.79 \times 10^7 \text{pm}^3.

Body-centered Cubic Unit Cells

A body-centered cubic unit cell has a lattice point in the middle of the cell, as well as at each corner:

A body-centered cubic cell with lattice points marked

Of note in the above picture is that the atom identified in purple is situated directly in the middle of the cell, at the intersection of the cube’s body diagonals.

One face of a body-centered cubic unit cell, with Molybdenum atoms marked

The technique used to solve the problem in the case of a simple cubic unit cell won’t work here, because the edge length is not an easily recognizable multiple of the radius of each atom. That is, if we look at one of the cell’s faces, we see there is a gap of unknown size between the two corner atoms (molybdenum in this case).

What we would like to do is determine the length of the edge; we do this by relating the body diagonal, the face diagonal, and the edge length via the Pythagorean theorem.

A body-centered cubic cell with face- and body-diagonals marked

Let b_d be the length of the body diagonal. Since there are two corner atoms each with width r and one atom in the center with width 2r, we can see that b_d = 4r.

Let f_d be the length of the face diagonal. By the Pythagorean theorem, f_d^2 = l^2 + l^2.

Applying the Pythagorean theorem to the triangle formed by the body diagonal, the face diagonal, and one of the edges gives b_d^2 = f_d^2 + l^2 \Leftrightarrow 16r^2 = 3l^2. Hence l = \frac{4r}{\sqrt{3}} and V = (\frac{4r}{\sqrt{3}})^3.

For molybdenum, whose atomic radius is 139 pm, V = 3.31 \times 10^7 \text{pm}^3.

Face-centered Cubic Unit Cells

A face-centered cubic cell has lattice points in the center of each face as well as at each corner. It does not have a lattice point in the center of the cell:

A face-centered cubic cell with lattice points marked

In the picture, the blue circles are corner lattice points, while the purple circles are face lattice points. The dashed purple circles are those lattice points obscured by other faces.

Looking at one of the faces, we can see that, unlike in a body-centered unit cell, the three nickel atoms touch along the face diagonal:

One face of a face-centered cubic unit cell, with Nickel atoms marked and the face diagonal noted

Thus the calculation in this case is actually fairly straightforward: f_d^2 = (4r)^2 = 2l^2. Hence, l = \sqrt{8}r and V = (\sqrt{8}r)^3.

For nickel, whose atomic radius is 124 pm, V = 4.31 \times 10^7 \text{pm}^3.

Posted by Chris on 6th October 2009

Potatoes au Gratin au Chicken — oh my

Prep time: 30 minutes. Cook time: 1 hour.

  • 3 red potatoes
  • 1 chicken breast
  • 1 clove garlic
  • 2 cups milk
  • 2 cups cheese (we use Colby Jack use a sharp Cheddar)
  • 3 tablespoons butter
  • 3 tablespoons flour
  • Some olive oil (probably no more than a teaspoon or two)
  • Salt and pepper
  1. Peel the potatoes and slice them as thinly as you can manage. More importantly, slice them evenly, lest you overcook some and undercook the rest. Distribute the slices evenly in a buttered 2-quart baking dish. Salt and pepper to taste.
  2. In a pot, melt the butter. Add the garlic and simmer for about a minute. Add the flour, mixing well, and let your chunky roux bubble for a minute or two.
  3. Slowly stir in the milk, being careful not to form floating roux chunks in a sea of milk. Impatience here leads to frantic stirring as you attempt to incorporate the flour. Stir constantly until the mixture thickens. Add the cheese; thoroughly mix and melt. Salt and pepper to taste.
  4. Pour the cheese sauce over the potatoes. Cook at 400°F.
  5. About 30 minutes later, heat the olive oil in a pan. Meanwhile, salt and pepper both sides of the chicken (don’t be afraid of using too much; you’re much more likely to use too little). Brown both sides of the chicken, about 3 minutes per side. Pull the potatoes out of the oven and plop the chicken in the middle; allow the potatoes and chicken to get friendly in the oven for another 30 or so minutes.

We ate this with corn on the cob—delicious!