Real-life based math problem
July 27, 2018 7:10 AM   Subscribe

On my daily commute back home, I drive past ~15 gas stations. In my country, gas prices change daily and vary a bit from one station to the next. So that got me thinking: What would be the best method to decide whether to fill your tank on the station you're currently in front of or lose the current price forever and take your chances on the remaining stations? Assume each station sets their daily price randomly (but they are all within a $1 range), and we start with the reference of the price we paid last time. Note: I can easily keep track of the lowest price on my way to work and then fill up on the way home, but I am more interested in the math problem than the practical issue.
posted by fjom to Science & Nature (9 answers total) 7 users marked this as a favorite
Best answer: This seems like it might be a variant of the secretary problem.
posted by smcameron at 7:16 AM on July 27, 2018 [7 favorites]

Best answer: It is the Secretary problem. The solution:
Note the lowest price among the first 5 (=15/e)
Buy gas at the next station with a lower price than that lowest, or at the last station if you got skunked.
posted by hexatron at 7:26 AM on July 27, 2018 [8 favorites]

Response by poster: I knew i couldn't have been the first one to think of this, thanks smcameron and hexatron!
posted by fjom at 7:39 AM on July 27, 2018 [1 favorite]

Best answer: Assume each station sets their daily price randomly (but they are all within a $1 range),

The gas prices are not completely random then but follow some reasonable bound. You also want to pay a lower price but are not, presumably, obsessed with getting the absolute lowest. This would mean that you should set your lowest price bound sooner - after say 3 gas stations.
posted by vacapinta at 8:08 AM on July 27, 2018 [3 favorites]

I was introduced to the problem (and solution) via the story of Kepler looking for a wife.
posted by clawsoon at 8:10 AM on July 27, 2018 [2 favorites]

It seems like the threshold should change based on how many are left (and the updated distribution). If you are on #14 (N-1) and it is better than the average so far, I think you should take it.
posted by tracer at 1:35 PM on July 27, 2018

If you're in this to get the best price (and not just as a thought exercise in the abstract), I wouldn't discount other real-life considerations, like average and historical prices for each gas station. It may be that there are other patterns that you could use to predict a more optimal outcome than what the Secretary problem's solution could give you. For instance, if station X tends to lag behind the average gas prices longer than other stations, you could use them when gas prices take an upward swing and avoid them on downward swings.
posted by Aleyn at 1:37 PM on July 27, 2018

As suggested by Aleyn, this not the Secretary Problem, it's the Repeated Secretary Problem. You should be able to learn some things as you go day-by-day.

Think about what causes the price to be different at different stations. There are two major reasons. 1) overall change in gas price from the suppliers, and 2) different policies at each station (or for each brand). For example, you may learn than the Exxon or Shell stations are higher priced than Hess or BP. Or the big, clean station with plenty of space is more expensive than the small dirty space where there is always a car in your way.

As for the changes that come due to events in the oil business, stores of most any kind price their products in one of two ways. They can set prices based on what the wholesale price they paid, or they set prices based on replacement cost, i.e. what they thing the wholesale price will be when they have to buy more. Or the higher of the two. In either case, stations with either big tanks or less business will tend to lag the market, while station with less storage capacity or a lot of business will tend to follow market trends more quickly.
posted by SemiSalt at 4:43 PM on July 27, 2018

Best answer: This is explained in vacapinta's link, but I want to amplify it a bit as it's a point easily overlooked: there is a range of possible objectives you might have here, and they call for different strategies. In the traditional secretary problem, the objective is to maximize the probability of getting the single best candidate -- to the complete exclusion of other considerations, such as whether you'll get the second-best or the worst if you fail. This unrealistic version of the problem has endured because it makes for some elegant mathematics! But chances are you'd rather minimize the average amount by which you can expect to overpay. That's what vacapinta's comment/link tells you how to do (but still under the assumption, not quite right in your scenario, that you don't know anything about the distribution of possible prices before you begin).
posted by aws17576 at 5:05 PM on July 27, 2018 [2 favorites]

« Older millennial straining to see...the future, yes, but...   |   Took my car in to get it repaired, but the repair... Newer »
This thread is closed to new comments.