1
我試圖讓我圍繞着如何使用pymc複製由道格拉斯·哈伯德電子表格在他的書中How to Measure Anything如何實現pymc
我的嘗試是在Python實現蒙特卡洛函數頭簡單蒙特卡洛功能:
import numpy as np
import pandas as pd
from pymc import DiscreteUniform, Exponential, deterministic, Poisson, Uniform, Normal, Stochastic, MCMC, Model
maintenance_saving_range = DiscreteUniform('maintenance_saving_range', lower=10, upper=21)
labour_saving_range = DiscreteUniform('labour_saving_range', lower=-2, upper=9)
raw_material_range = DiscreteUniform('maintenance_saving_range', lower=3, upper=10)
production_level_range = DiscreteUniform('maintenance_saving_range', lower=15000, upper=35000)
@deterministic(plot=False)
def rate(m = maintenance_saving_range, l = labour_saving_range, r=raw_material_range, p=production_level_range):
return (m + l + r) * p
model = Model([rate, maintenance_saving_range, labour_saving_range, raw_material_range, production_level_range])
mc = MCMC(model)
不幸的是,我發現了一個錯誤:ValueError: A tallyable PyMC object called maintenance_saving_range already exists. This will cause problems for some database backends.
我有什麼錯?
PyMC可能有自己的對象叫做maintenance_saving_range。嘗試重命名您的變量,例如my_maintenance_saving_range。 –
你說得對。我只是笨拙的複製粘貼代碼。 – elksie5000