Exercise

Modeling Profits

In the previous exercise, you built a model of corn production. For a small farm, you typically have no control over the price or demand for corn. Suppose that price is normally distributed with mean 40 and standard deviation 10. You are given a function corn_demanded(), which takes the price and determines the demand for corn. This is reasonable because demand is usually determined by the market and is not in your control.

In this exercise, you will work on a function to calculate the profit by pulling together all the other simulated variables. The only input to this function will be the fixed cost of production. Upon completion, you'll have a function that gives one simulated profit outcome for a given cost. This function can then be used for planning your costs.

Instructions

100 XP
  • Model the price as a normal random variable with mean 40 and standard deviation 10.
  • Get the corn supply by calling the function corn_produced(rain, cost), which you designed in the previous exercise.
  • Call the corn_demanded() function with input price to get demand.
  • Profit \(=\) quantity \(\times\) price \(-\) cost. If more corn is produced than demanded (supply > demand), then quantity sold will be demand, else it will be supply.