1
$\begingroup$

Here are some key data to use for calculation:

  1. initial population is 100, and average food consumption per person is 5lbs of rice each week
  2. 1~2% of population dies off every month
  3. 20~40 is added to population every month
  4. average rice consumption per person increases by 0~2.5% weekly

Assumptions:

  • assume all random variables are independent
  • assume all variables are uniformly distributed across the given range.

Here is the question:

How is the food consumption growth of the population for the next 5 months in the 10th, 50th, and 90th percentile cases?

note:

this is a take home assessment that i cannot do. for personal growth, i'd like to learn how to do such problem. I feel like it'd be useful for IRL as well. i don't even know what to google to solve for this problem, hence i'm turning to this community for some suggestion/guidance/solution.

Thank you very much in advance.

$\endgroup$
3
  • $\begingroup$ Do you know what the percentiles refer to? My initial guess would be the percentiles of a number of simulations of possible outcomes. $\endgroup$ Commented Feb 17, 2020 at 11:26
  • $\begingroup$ @alanocallaghan nope. that's what how the question was worded. i assumed it was the percentile of food consumed. does my assumption make sense? i read your answer it seems to make a lot more sense than mine... $\endgroup$ Commented Feb 17, 2020 at 20:09
  • $\begingroup$ There's two possible interpretations that make sense to me. One is that it's the quantiles of food consumed by individual people, but in that case the information about population size, death etc is mostly irrelevant, other than in determining how likely it is that someone will survive for the next month. The other is the one I showed $\endgroup$ Commented Feb 17, 2020 at 20:24

1 Answer 1

2
$\begingroup$

This is a nice and neat simulation that I can demonstrate with R code. I would start off by defining the initial values:

population <- 100
consumption_rate <- 5

Next, we could define a few functions to vary the population parameters, as specified in the 3 steps:

## Take a uniform value in 0.01-0.02 as a percentage of our current population
death_rate <- function(population) {
  prop <- runif(1, 1, 2) / 100
  round(population * prop)
}
## Generate a random number births in range 20-40
birth_rate <- function() {
  round(runif(1, 20, 40))
}
## Generate an 0-2.5% increase in consumption rate
consumption_increase <- function(consumption_rate) {
  increase <- runif(1, 0, 2.5) / 100
  consumption_rate * (1 + increase)
}

The final step would be to run a number of simulations where we chain these simple functions together. The function replicate is very useful for situations like this.

simulations <- replicate(10000, {
    total_consumption <- 0
    for (i in 1:5) {
      population <- population - death_rate(population)
      population <- population + birth_rate()
      consumption_rate <- consumption_increase(consumption_rate)
      consumption_this_month <- population * consumption_rate
      total_consumption <- total_consumption + consumption_this_month
    }
    total_consumption
  }
)

We now have total cumulative consumption measures from each of these 5 month simulations, and can easily visualise and calculate quantiles:

hist(simulations, breaks = "FD")
q <- quantile(simulations, c(0.1, 0.5, 0.9))
abline(v = q, lty = "dashed")

You'll no doubt notice that the results of the product of all of these uniformly distributed processes is actually (approximately) a normal distribution.

Note: the order in which actions happen (births, deaths, increase in consumption) in the simulation loop could have a strong effect on the outcome. This is something you would have to think about, I've just picked an arbitrary order.

$\endgroup$
1
  • 1
    $\begingroup$ hi @alan thanks so much for your help! its a great learning for me! $\endgroup$ Commented Feb 18, 2020 at 6:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.