开始使用免费开始使用

玉米产量建模

假设您经营着一家小型玉米农场,想要优化成本。在这个示例练习中,我们将对玉米产量进行建模。我们会忽略单位等细节,专注于过程。

为简单起见,假设玉米产量只取决于两个因素:您无法控制的降雨量,以及您可以控制的成本。降雨量服从均值为 50、标准差为 15 的正态分布。现在先将成本固定为 5,000。再假设任一季节的玉米产量服从 Poisson 随机变量,且平均产量由以下公式决定:

\(100\times(\text{cost})^{0.1}\times(\text{rain})^{0.2}\)

让我们对这个生产函数建模,并模拟一个结果。

本练习是课程的一部分

Python 中的统计模拟

查看课程

练习说明

  • rain 初始化为均值为 50、标准差为 15 的 Normal 随机变量。
  • corn_produced() 函数中,将 mean_corn 建模为 $ 100\times\text{cost}^{0.1}\times\text{rain}^{0.2} $。
  • corn 建模为均值为 mean_cornPoisson 随机变量。
  • 通过将调用 corn_produced() 的结果存入 corn_result 并打印结果,来模拟一次产量。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Initialize variables
cost = 5000
rain = np.random.____

# Corn Production Model
def corn_produced(rain, cost):
  mean_corn = ____
  corn = np.random.____
  return corn

# Simulate and print corn production
corn_result = ____
print("Simulated Corn Production = {}".format(____))
编辑并运行代码