-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot.py
71 lines (57 loc) · 1.81 KB
/
plot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
INCOME_PREMIUM_USER_PER_MONTH = 5
NUMBER_REQS_PER_USER_PER_MONTH = 40
NUMBER_REQS_PER_USER_PER_MONTH_FREE = 5
NUMBER_REQS_CHECKED_PER_EXPERT_PER_MONTH = 1000
PAYMENT_PER_EXPERT_PER_MONTH = 3000
FIXED_PAYMENT_PER_REQUEST_API = 0.0002
FIXED_PAYMENT_PER_MONTH = 275
RATIO_OF_FREE_USERS = 0.5
x = np.arange(1, 1000)
# number of expert checks required decreasses with the number of users
EXPERT_CHECK_RATIO = np.exp(-x / 1000)
costs = (
# costs for free users API
(
NUMBER_REQS_PER_USER_PER_MONTH_FREE
* FIXED_PAYMENT_PER_REQUEST_API
* x
* RATIO_OF_FREE_USERS
)
# costs for premium users API
+ (
NUMBER_REQS_PER_USER_PER_MONTH
* FIXED_PAYMENT_PER_REQUEST_API
* x
* (1 - RATIO_OF_FREE_USERS)
)
# fixed costs
+ FIXED_PAYMENT_PER_MONTH
# costs for expert checks
+ (
(x / NUMBER_REQS_CHECKED_PER_EXPERT_PER_MONTH * PAYMENT_PER_EXPERT_PER_MONTH)
* EXPERT_CHECK_RATIO
)
)
revenue = INCOME_PREMIUM_USER_PER_MONTH * x * (1 - RATIO_OF_FREE_USERS)
profit = revenue - costs
matplotlib.rcParams["axes.spines.left"] = False
matplotlib.rcParams["axes.spines.bottom"] = False
matplotlib.rcParams["axes.spines.right"] = False
matplotlib.rcParams["axes.spines.top"] = False
matplotlib.rcParams["lines.linewidth"] = 3
plt.grid(True, alpha=0.5)
plt.plot(x, costs, label="Costs")
plt.plot(x, revenue, label="Revenue")
plt.plot(x, profit, label="Profit")
plt.xlabel("Number of users")
plt.ylabel("Dollars ($)")
plt.legend(bbox_to_anchor=(1.0, 1.0))
plt.savefig("plot.png", dpi=300, bbox_inches="tight")
plt.figure()
plt.plot(x, EXPERT_CHECK_RATIO)
plt.xlabel("Number of users")
plt.ylabel("number of requests per month")
plt.savefig("plot_ratio.png", bbox_inches="tight")