陷入总收入,平均收入和边际收入的问题

时间:2019-04-02 03:27:05

标签: python python-3.x

我正在尝试在线查找利润最大化的样例。我今天看了一会儿,没有提出任何有用的建议。基本上,我试图弄清楚如何创建一个假设的方案来询问通用产品的价格,售出的数量(数量随价格的增加而降低)以及价格的弹性。另外,我想查看总收入,平均收入和边际收入,并绘制所有线条。我希望剧情看起来像这样。

enter image description here

我想出了这个,但是我认为它太简单了。

import pandas as pd
import numpy as np


Q1 = float(input("Input quantity 1: "))
Q2 = float(input("Input quantity 2: "))
P1 = float(input("Input price 1: "))
P2 = float(input("Input price 2: "))
sPrice = float(input("Input price 1: "))
ePrice = float(input("Input price 2: "))


# print(Q1,Q2,P1,P2)

lst = np.arange(sPrice, ePrice, -1)
#print(lst)

df = pd.DataFrame(lst)
df.columns = ['Price']

df['Quantity'] = Q1 - Q2 * df.Price

df['Elasticity'] = Q2 * (df['Price']/-df['Quantity'])

df['TR'] = df['Price'] * df['Quantity']

df['AR'] = df['TR']/df['Quantity']

df['MR'] = P1 - 2 * P2 * df['Quantity']
print(df)


Input quantity 1: 59
Input quantity 2: 2.3
Input price 1: 25.65
Input price 2: .435
Input price 1: 25
Input price 2: 0


    Price  Quantity  Elasticity     TR    AR      MR
0    25.0       1.5  -38.333333   37.5  25.0  24.345
1    24.0       3.8  -14.526316   91.2  24.0  22.344
2    23.0       6.1   -8.672131  140.3  23.0  20.343
3    22.0       8.4   -6.023810  184.8  22.0  18.342
4    21.0      10.7   -4.514019  224.7  21.0  16.341
5    20.0      13.0   -3.538462  260.0  20.0  14.340
6    19.0      15.3   -2.856209  290.7  19.0  12.339
7    18.0      17.6   -2.352273  316.8  18.0  10.338
8    17.0      19.9   -1.964824  338.3  17.0   8.337
9    16.0      22.2   -1.657658  355.2  16.0   6.336
10   15.0      24.5   -1.408163  367.5  15.0   4.335
11   14.0      26.8   -1.201493  375.2  14.0   2.334
12   13.0      29.1   -1.027491  378.3  13.0   0.333
13   12.0      31.4   -0.878981  376.8  12.0  -1.668
14   11.0      33.7   -0.750742  370.7  11.0  -3.669
15   10.0      36.0   -0.638889  360.0  10.0  -5.670
16    9.0      38.3   -0.540470  344.7   9.0  -7.671
17    8.0      40.6   -0.453202  324.8   8.0  -9.672
18    7.0      42.9   -0.375291  300.3   7.0 -11.673
19    6.0      45.2   -0.305310  271.2   6.0 -13.674
20    5.0      47.5   -0.242105  237.5   5.0 -15.675
21    4.0      49.8   -0.184739  199.2   4.0 -17.676
22    3.0      52.1   -0.132438  156.3   3.0 -19.677
23    2.0      54.4   -0.084559  108.8   2.0 -21.678
24    1.0      56.7   -0.040564   56.7   1.0 -23.679

0 个答案:

没有答案