Session Ready
Exercise

Optimizing Costs

Now we will use the functions you've built to optimize our cost of production. We are interested in maximizing average profits. However, our profits depend on a number of factors, while we only control cost. Thus, we can simulate the uncertainty in the other factors and vary cost to see how our profits are impacted.

Since you manage the small corn farm, you have the ability to choose your cost - from $100 to $5,000. You want to choose the cost that gives you the maximum average profit. In this exercise, we will simulate multiple outcomes for each cost level and calculate an average. We will then choose the cost that gives us the maximum mean profit. Upon completion, you will have a framework for selecting optimal inputs for business decisions.

Instructions
100 XP
  • Initialize the empty dictionary results.
  • For each cost level, simulate profits using the pre-loaded profits() function and append them to tmp_profits.
  • Store the average of tmp_profits for each cost level in the results dictionary.
  • Find the cost level cost_max that has the maximum average profit by running results through the list comprehension.