April 13th, 2008

Welcome to my newly created math blog.

Look here for discussion and solutions to short problems — usually, something that might take me an hour or less to write.  For more detailed analysis that takes days, weeks, or even months, visit my math page.

I read an article in the newspaper recently and I read something I could not believe. The article was about Disneyland’s “It’s a Small World” ride being shut down to make modifications possibly because of the expanding waistlines of riders. That part was believeable. The unbelieveable part (at least to me) was that it said the average weight of American women (aged 20-74) is 164 pounds.

Yes, that’s right, 164 pounds. Do you believe it? I didn’t. I couldn’t think of any female friend who weighs that much. Admittedly, a large percentage of the female friends I have are Asian, so perhaps my sample is skewed. Still, I found it hard to believe. So I looked for and found the CDC report online. You can view it here:


It’s from 2004 and I couldn’t find anything wrong with it. I wondered if their sampling size was too small, or if it was unfairly biased (in scientific terms). But it looks like they’ve done a thorough job. My only complaint is that it (along with many other surveys I’ve seen) doesn’t include “Asian” as a race category. It only breaks it down into hispanic, non-hispanic white, and non-hispanic black. I’d be very interested to know what the average is for Asians, but I couldn’t find that information on the web.

So I guess I have to accept the results as fact. But I can still continue along on this note by asking the question: suppose I wanted to survey people and ask them for their weight. Assuming that many would be reluctant to tell the truth, can I get an accurate average?

This is similar to a problem solved in the book “Struck By Lightning” which I read a couple months ago. Basically it involves adding some randomness to the survey. We can extend that idea to this problem. (warning, math ahead)

Instead of simply asking for a person’s weight, we’ll do the following: Have the person roll a die, without letting us see the result. Tell them that if it comes up 1, tell us their exact weight. If it comes up 2, tell us their weight plus 10 pounds. If it comes up 3, tell us their weight plus 20 pounds, etc. This would help some. If someone then tells us their weight is 150 pounds, their actual weight is somewhere between 100 and 150 pounds, but we have no way of knowing what it is. But since we know the probability of each die roll is the same, the average difference is 25 pounds, so to get the average, we simply subtract 25 pounds from the average of all the weights we are told. Assuming our sampling size is large enough, we should have an accurate average.

The downside to this approach is that if someone rolls a 6 and has to tell us their weight plus 50 pounds, they may be reluctant to do so since we know they can’t weigh any less than 50 pounds less than the number they tell us.

One way to solve this problem would be to tell them that if they roll a 6, roll the die again. Keep rolling as long as they roll a 6, adding 50 pounds each time they roll a 6. This way, there’s no bound to how much they have to add, so there’s no conclusion we can draw if they tell us they weigh 995 pounds. Well, we can conclude that they got extremely unlucky with the die rolls, but it gives no clue as to their actual weight. The math gets a little more tricky, though. The adjustment to the average is no longer 25 pounds.

Let A = (1/6) * (0 + 10 + 20 + 30 + 40).

Then the adjustment is A + (1/6) * (50 + A + (1/6) * (50 + A + …))

I’m sure there’s some relatively simple mathematical method to figure out the exact answer (possibly related to continued fractions), but it’s 1:30am so I should probably go to sleep. I will say that I expanded it out a few terms and it looks to be about 30. I wouldn’t be surprised if it’s exactly 30 (maybe I’ll work out the details tomorrow).

Ok, I’m still awake. I’m a sucker for a math problem.

Let S = A + (1/6) * (50 + A + (1/6) * (50 + A + …))


A + (1/6) * (50 + S) = A + (1/6) * (50 + A + (1/6) * (50 + A + …))
A + (1/6) * (50 + S) = S
A + 50/6 + S/6 = S
A +50/6 = S * (5/6)
S = (A + 50/6) * (6/5)
S = (150 / 6) * (6/5)
S = 150/5 = 30

Aha! Now I can sleep.

Gas Station Probability

October 16th, 2007

This morning, when I went to get gas for the car, I saw something I don’t think I’ve ever seen before. I saw someone changing the sign that shows the gas prices.

Now, I know that they do this, but I’ve never been there while they do it. I’m guessing this is probably because they do it very early in the morning or late at night, when I’m less likely to be at the gas station. For the record, I was there around 9:20am, and the guy making the change was using a very long pole (about 15 feet) with a suction cup at the end to pull the numbers up. Despite his best efforts, he ended up dropping all of the numbers on the ground. I was going to say that an electronic sign might be more cost-effective, but then I realized that most gas station attendants don’t have much to do a lot of the time, since payments are mostly handled automatically. So I guess you might as well put them to work. On the other hand, maybe Chevron hires one person to change all the signs in an area. A sign-changing expert? Who knows.

In any case, I got to thinking (because this is what I do): what if they didn’t do it early in the morning or late at night? What if they did it randomly at some time during the day. Is it that unlikely that I would never see them change it?

Warning: Math ahead!

So let’s do some rough calculations. 

Suppose I drive about 15,000 miles a year. If I get 300 miles per tank, that’s about 50 fillups per year. But I don’t usually wait until the car is running on fumes, so probably 60 fillups per year is more accurate. I’ve been doing this for about 13 years, for a total of about 780 fillups. Let’s suppose each fillup takes about 6 minutes. Let’s make some wild guesses and say they change the price of gas about 100 times a year, and it takes an average of 10 minutes for the sign change (lower signs are quicker, higher signs take longer). Given all those variables (which may or may not be anywhere near accurate), how would we go about calculating the expected number of times I should have seen them change the price during my 13 years of filling up?

Let’s first look at the simpler question of the probability of seeing them change the price during a single fillup. They change the signs for a total of about 100×10 = 1000 minutes per year. There are 60*24*365 = 525600 minutes per year. So if I did a single 1-minute fillup, the chances of me seeing them change the sign would be 1 in 525.6. At first glance, you might think my chances with a 6-minute fillup would be 6 in 525.6. But that would be wrong. The simplest way to see it’s wrong is to note that using the same approach would say that a 525.6 minute fillup would lead to a 100% chance of seeing them change the price. Which is obviously wrong.

Arg. It’s hard for me to do this while I’m scanning pictures in, and I don’t see a way to save a work in progress, so I guess I’ll just publish this and finish it later…

Ok, I’m back.

Let’s analyze a single fillup. Let’s assume that they never change the price twice in one day. It’s probably true, and even if it’s not it won’t affect our analysis much. So the chances that they change the price the same day we fill up is 100/365 = 1/3.65. Let’s now assume that our fillup starts at the start of a minute, and they change signs at the start of a minute. We’ll do a more accurate analysis later, but let’s start with that. There are 60*24 = 1440 minutes in a day. If we further assume that a price change and a fillup do not span multiple days, then there are 1431 different time slots for the price change, 15 of which overlap our 6 minute fillup. So the chances of us seeing the price change is 15/1431 = 1/95.4.

What if we did the same analysis but allowed the time slots on second boundaries instead of minute boundaries? Well, let’s generalize even further and do the analysis on boundaries on time T, where T is in minutes. So T = 1/60 would be the same analysis in seconds. There are (1440/T) units of time T in a day. So there are (1430/T) + 1 different time slots for the price change, (16/T – 1) of which overlap our 6 minute fillup. So the chances of us seeing the price change is (16/T – 1) / (1430/T) + 1 = (16 – T) / (1430 + T) which, as T approaches 0, is clearly 16 / 1430 = 1/89.375.

Since we fill up 60 times a year, the chance of us not seeing the price change on all of those fill-ups is (1 – 1/89.375) ^ 60 = 0.509.

The chance of us not seeing the price change over 13 years is (1 – 1/89.375) ^ (13 * 60) = 0.0001543228 = 0.15% Which means there’s only a 1 in 6480 chance of us not having seen a price change. Which strongly suggests that they change the prices while I’m asleep or at work, and not in the mid-morning when I often fill up.

What’s the expected number of times I would have expected to see a price change? That’s simply (13 * 60) * (1/89.375) = 8.73.

So I should have seen about 9 price changes in those 13 years.

Of course, if any of my time estimates are wrong, then I’ll have to adjust my analysis. Maybe I’ll time myself at the gas station for the next month or so. :)

One other note: if my fill-up times are not random, but the gas station’s price changes are completely random, then it’s equivalent to us both being random. At least as far as the probability of me seeing the price change goes. This is also the same as my fill-up times being completely random, and the gas station not being random.

In any case, I will probably clean up this analysis and put it up on my Math web site in the near future…