def profits(q):
range_price = range_p(q)
range_profits = [(x-c(q))*demand(q,x) for x in range_price]
price = range_price[argmax(range_profits)] # recall from above that argmax(V) gives
# the position of the greatest element in a vector V
# further V[i] the element in position i of vector V
return (price-c(q))*demand(q,price)
print profits(0.6)
print profits(0.8)
print profits(1)
0.18
0.2
0.208333333333
随着q
(即质量),我们知道,最大化质量1
。现在的问题是,我该如何解决这样一个方程?我一直收到的错误是q
尚未定义(这只是我们正在寻找它的时候很自然),或者我得到了一些错误的观点。fminbound在<code>[0,1]</code>一个简单的等式
q_firm = optimize.fminbound(-profits(q),0,1)
这是我尝试过,但我得到这个错误:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-99-b0a80dc20a3d> in <module>()
----> 1 q_firm = optimize.fminbound(-profits(q),0,1)
NameError: name 'q' is not defined
有人能帮助我吗?如果我需要提供给你们更多的信息让我知道,这是我第一次使用这个平台。提前致谢!
你在哪里定义'q'? – Forge
无处,我们需要优化它以获取最大利润。 –
@Forge看看上面,很抱歉没有提到你早些时候(我仍然是这里的菜鸟)。 –