# Randomized Dinner Planning

**5/20/16**

Note, the randomized meal planner and this article have been thoroughly updated as of 10/26/17.

I use a sampling technique called "probability proportional to size", or PPS, at work, and at home, for a variety of things. For example, at work, it is used to sample companies based on a measure of size like payroll. At home I use the technique for creating workouts, where I sample from a list of exercises based on various criteria, to randomize flash cards for learning Braille, and many other things. My wife and I thought it could be used to plan our family's dinners.

We started this project by making a list of some recipes that we've done before. We included the general duration (estimates are OK!) it takes to prepare and cook a meal. We also included a list of general ingredients for each meal. When we originally did this, we just thought about Dinner. However, this has now been extended to include Breakfast, Snack 1, Lunch, Snack 2, and Dinner.

For the "measure of size" to sample by that PPS requires, we originally used Duration. Actually, we sampled by 1/Duration, since people are more likely to make dinners that don't take as long to prepare. We also have a general base "Weight" that we used to further control the frequency of recipe selection, for example, increasing the weight for a meal we enjoy so it gets sampled with a higher frequency. Or if a friend uses the spreadsheet, but that friend is vegetarian, they can set weight = 0 for any meal that has meat in it so that meal will __not__ be selected.

In practice we found out that we tend to ignore the Duration variable since so many durations are similar, and nothing takes too long to prepare for us. So we just focus on the user-inputted Weight variable to control the sampling. It also allowed us to add options for eating out (ie. preparation time = 0, for us anyway!) to Dinners to be sampled from.

Here is what the parameters and 2-week display parts of the spreadsheet look like

Note that each Breakfast, Snack 1, Lunch, Snack 2, and Dinner area have their own parameter section. Actually, Snack 1 and Snack 2 are combined into a single Snacks section. One could make these snacks sections separate, or even add a midnight snack section, or a desserts or drink section, a similar idea for birthday parties, restaurant menus, etc. The possibilities are endless.

Note that this is just one possible realization of a plan for 2 weeks.

Some other sections of the randomized meal planner are the constraints and simulation sections.

As mentioned, we select recipes for two weeks out. Note that we don't necessarily follow this rigidly. This is more for generating ideas, variety, and helping to make shopping easier. However, just because selections are made, that doesn't mean they satisfy all of our criteria. Therefore I included some checks that were important to us. For example, some possible constraints are:

- Breakfast appears more than X times in 2 weeks (user inputs X)
- Snack 1 appears more than X times in 2 weeks (user inputs X)
- Lunch appears more than X times in 2 weeks (user inputs X)
- Snack 2 appears more than X times in 2 weeks (user inputs X)
- Dinner appears more than X times in 2 weeks (user inputs X)
- Same Breakfast 2 or more days in a row
- Same Lunch 2 or more days in a row
- Same Dinner 2 or more days in a row
- Snack 1 and Snack 2 are the same for any day
- French toast for Breakfast does not appear in 2 weeks (user inputs meal)
- eating out appears more than X times (user notes what meals are eating out, user inputs X)
- eating out appears less than X times (user notes what meals are eating out, user inputs X)

Users can, and probably should, input their own set of constraints. If any of these checks fail, we simply press F9 which regenerates the random numbers and selections. Here is what the constraints section looks like:

Here are a few examples of lists that meet our requirements:

And here a few examples list that do not meet our requirements (and therefore we would need to refresh the random numbers until a good list is selected). I put red boxes on the spreadsheet to highlight the problems:

Of course, this brings up an interesting theoretical and practical question. Just how many times do we need to refresh the spreadsheet before we get a good list? This is where the simulation section comes in. We have a cell that is a 1 if a list doesn't meet our requirements and 0 otherwise. Then we keep track of these results for an inputted number of iterations and take the average of those results to get the % of time we need to refresh the list. If we subtract that from 1, we get the % of time we created a good list. And if we do 1 divided by *that* number, we get the approximate number of times we need to refresh the list in order to get a good list.

Here are the results from a simulation of 1,000 iterations using our constraints above.

So we get, on average, 1 good list every 22 times we refresh the list.

Obviously, the more constraints one has, the longer it will take to get a good list. If we just have this constraint "Breakfast appears more than X times in 2 weeks (user inputs X)", we get the following results for 1,000 iterations:

On average 1 good list every time we refresh the list.

Note that if we don't take any constraints into consideration, and if there are say 25 choices for Breakfast, 55 choices for Snack 1, 33 choices for Lunch, 55 choices for Snack 2, and 54 choices for Dinner, because sampling is done without replacement, there a total of 25*55*33*55*54 = 134,763,750 possible combinations for a given day! This equates to 943,346,250 possible combinations for a week, and 1,886,692,500 possible combinations for a 2 week time period.

Here is the Visual Basic code I use to carry out the simulation.

Here is a link to download the spreadsheet. Familiarity with Excel will help you with using the spreadsheet. Feel free to contact me if you have questions. I hope your family can use this for meal planning.

Thank you for reading and sharing!

If you enjoyed *any* of my content, please consider supporting it in a variety of ways:

- Email news@statisticool.com to sign up to receive news and updates
- Donate any amount via PayPal
- Take my Five Poem Challenge
- Buy ad space on Statisticool.com
- Buy what you need on Amazon using my affiliate link
- Follow me on Twitter here