A Competition-Based Version of Ray's Lemonade Selling Simulation

Many of you probably saw Ray Camden's Lemonade Stand Contest Results. I had fun creating a function to enter into that contest, but I lost! Congrats to Geoffrey K. Bentz as the winner.

I was curious, though, to see how the functions would perform in a slightly more realistic simulation. Ray's selling simulation basically treated each function in a vacuum, and the main factor was in making the most cups that you could and selling them for the most money, based on the weather and temperature. That may sound obvious, but if a more competitive environment is created, things aren't quite so straightforward. You need to make an appropriate number of cups, and you need to charge as much as you can for them, but you also need to avoid being priced far above your competition.

Well I went ahead and wrote a version of the simulation that tries to take this into account. It's far from perfect, but basically what it does is:

  1. It loops over each day like the original does
  2. It determines the predicted and actual temperature and weather like the original does
  3. It then feeds the prediction temp and weather into each function and gets back its number of cups and its price
  4. It sorts the stands in order by cup price, lowest first
  5. It begins the buying simulation by creating a default pool of customers equal to the number of stands * 100
  6. It sets a default maximum acceptable price of 50 cents per cup
  7. It modifies the number of customers and the acceptable max price based on the weather and temperature. In general, nicer weather and hotter temperature increase the customers and the max price, and bad weather and lower temperature decrease customers and their max price.
  8. It loops over the set of customers and divides them into groups. The group sizes are random, to simulate "waves" of customers coming up to the lemonade stands
  9. As each group is processed, each person has their max acceptable cup price randomized between +/- 12 cents of the base max price, to provide variability
  10. The first person in the group finds the stand with the cheapest price that still has cups available and whose price doesn't exceed the customer's randomized maximum price
  11. When a customer picks their stand, that stand becomes "occupied" and is now not available for other customers in this group. The next customer finds the next best price, etc.
  12. The variable group sizes are run through until the total number of customers is reached
  13. At that point, the number of cups each stand sold, along with their profit and budget, are saved
  14. The day ends and the next day begins

In this way, it's important to sell at a price that makes the stand money, but not so high that its far above what the others are selling for. Even stands selling for cheap prices are out of luck if they don't make enough. Conversely, since the size of the crowds are randomized, as are their price limits, it is easy for a stand to make too many cups and not sell them all.

I ran a 30 day cycle through 30 runs and came up with average rankings for each stand. I also determined the standard deviation for each stand, which is an indicator of consistency. A stand with a large standard deviation was more erratic in its ranking, while a low standard deviation means less variability in its rankings over time.

The level of built-in variation in the simulation causes the results to shift around a bit, but in general Geoffrey Bentz still comes out on top. Usually followed by myself or Mat Evans. Kudos to Stephen Withington, since even though he is not usually the winner, he has a very consistent ranking (low standard deviation) around the 4 or 5 spot. Curt Gratz also does well (I fixed Curt's function to properly deal with cents instead of dollars).

Interestingly, and maybe something of a validation that the more competition-driven simulation actually makes a difference, is that Ray's test "smarterseller" function tended to be in the bottom half of results. Since all that function does is make as many cups as it can, and ignores weather to ramp up the price based on temperature, perhaps that should be expected? This function probably ended many days with a lot of unsold cups.

Anyway, some example results are below. If you are interested, you can see and run the modified simulation code. Thanks again to Ray for running this! Writing the little simulation version was an interesting exercise. Maybe someone else will try an alternate approach or try some of the other ideas that were thrown out (like actually reading historical weather data, or applying a weather pattern algorithm).

Sales Results Across 30 Runs of 30 Days Each

Stand Average Ranking ± Std. Deviation
BENTZ 3.87 ± 3.88
MATEVANS 4.70 ± 5.41
BRIANKOTEK 5.37 ± 3.23
CURTGRATZ 6.03 ± 2.88
PADDYROHR 6.10 ± 4.70
STEPHENWITHINGTON 6.37 ± 2.69
CFSILENCE 6.77 ± 3.65
JOHNERIC 8.00 ± 2.48
MATTOSBUN 9.63 ± 4.53
JOELSTOBART 9.80 ± 2.84
SMARTERSELLER10.83 ± 5.96
GENTRYD 10.83 ± 2.37
MATTJONES 11.03 ± 2.59
BRADWOOD 11.27 ± 3.07
TUTTLE 12.40 ± 3.59
CISKE13.93 ± 2.26
COYNE 16.07 ± 1.15

Remember:
  • Look not only at the average ranking, but at the standard deviation.
  • A lower standard deviation means that stand was more consistent in its ranking.
  • A higher standard deviation means that stand had a wide variability in its rankings.
  • So in the end, consistent performance and a good ranking really make the best stands.

Comments
he he. very clever. now how about adding lemonade quality and distance from other stands into calculations? i am sure that is why Ray's smartseller won before - it made better lemonade! :)
# Posted By Azadi Saryev | 7/16/08 12:59 AM
Lol...I was just *joking* we when talked about the need for a market-based simulation to get better results!

Two questions:

1. When a stand becomes 'occupied', will a customer automatically move to the next open stand, or is there a price difference threshold at which they'll shift? (A customer may stand in line at Stand A if it was 15% +/- (randRange(0, 5)% cheaper than Stand B, which has no line).

2. Do customers have brand loyalty? If I shop with Bentz on Monday, is the decision weighted towards Bentz on Tuesday? Or maybe weighted away, in case Bentz forgot the sugar or was being rude? Maybe there should be a 'customer satisfaction' factor, where one in 4-5 customers isn't happy with their experience and won't use the same person twice, but would otherwise have a weighted decision the next day.
# Posted By Joe Rinehart | 7/16/08 8:00 AM
yeah I agree, very clever!

I might try running these over a whole year and see how it pans out, tbh i think people will maintain the same rough position but there might be some surprises.

Thanks!
# Posted By Mat Evans | 7/16/08 8:14 AM
@Joe: no, no line standing logic or anything, if a stand is occupied they just go on to the next best stand (cheapest price that still has cups left and is under their maximum). Note this does mean that towards the end, it is possible for a customer not to buy from anyone if all that is left are expensive stands.

Also, no brand loyalty, I basically assumed that each day's pool of customers was unique.
# Posted By Brian Kotek | 7/16/08 8:23 AM
This simulation doesn't factor in the chick in the bikini that I have at my stand....
# Posted By todd sharp | 7/16/08 8:30 AM
It would be interesting to factor in the ability to devote some of your budget to advertising!
# Posted By Brian Kotek | 7/16/08 8:35 AM
@Brian,

Great follow-up! And by the way, do you think 'low standard deviation' would look good on a resume?
# Posted By Steve Withington | 7/16/08 8:54 AM
Now that you've introduced competition with the lowest price winning, my scheme would be to create one that gives away FREE lemonade, but has bikini women and asks for a DONATION to some unspecified cause! ;-)

Modeling human behavior is a hard beast. This is a great 2nd look at the lemonade stand; interesting read. :-)
# Posted By Dan Sorensen | 7/16/08 10:20 AM
I am curious as to how you decided on $0.50 as the max price. Did you figure out what the average sale price is across all the entries?

I think my entry must be selling much higher than most of the others. Bumping the max price up to $1.25 puts me up at the top from the very bottom when set at $0.50. :) Interesting.
# Posted By Sean Coyne | 7/16/08 2:26 PM
I actually just took the average price for producing a cup of lemonade (3-8 cents) and picked a number that I thought would be realistic and still provide a profit (a huge profit, in this case). $1.25 seems to me a bit over the top for a cup of lemonade that cost 3 cents to make (4000% increase). However, I do wish that Ray had supplied some sort of "average price range" for lemonade so that all the functions at least were working in the same ball park for setting their price.
# Posted By Brian Kotek | 7/16/08 2:58 PM
My suspicions were correct. My stand sells on average for much much more than any other stand on average (hope this is formatted OK after I submit). Guess I was too greedy :)

COYNE - $2.07
BENTZ - $0.39
MATEVANS - $0.35
SMARTERSELLER - $0.34
BRIANKOTEK - $0.32
STEPHENWITHINGTON - $0.21
CURTGRATZ - $0.19
TUTTLE - $0.17
PADDYROHR - $0.16
JOHNERIC - $0.15
BRADWOOD - $0.14
MATTJONES - $0.12
CFSILENCE - $0.11
MATTOSBUN - $0.11
JOELSTOBART - $0.11
CISKE - $0.10
GENTRYD - $0.08
# Posted By Sean Coyne | 7/16/08 3:53 PM
Awesome job Brian-- I like what you did. It's sad to see my stand still didn't do too well, but I think having a predefined expectation of what the average price should be would have made quite a difference. I printed out the list of your winners next to the list of average prices that Sean Coyne listed and drew lines across. For the most part, the rankings were tied very closely to the average cup price. The only two real exceptions were Coyne and Smart Seller. Presumably because Sean's prices were so high and Smart Seller ignored the weather.
Here was my analysis:
http://www.codersrevolution.com/index.cfm/2008/7/1...
# Posted By Brad Wood | 7/17/08 10:59 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.9.1. Contact Blog Owner