質問編集履歴

1

追記

2020/08/13 03:56

投稿

melonattacker
test CHANGED
File without changes
test CHANGED
@@ -83,3 +83,71 @@
83
83
  print("u_t:", u_t) # ここが①のu_tと等しければ正解
84
84
 
85
85
  ```
86
+
87
+
88
+
89
+ # 追記
90
+
91
+ `scipy.optimize.newton`を用いて、解くことができました。
92
+
93
+
94
+
95
+ ```Python
96
+
97
+ import numpy as np
98
+
99
+ import math
100
+
101
+ from scipy import integrate, optimize
102
+
103
+
104
+
105
+ beta = 0.3
106
+
107
+ chi = 1.0
108
+
109
+ productivity = 100.0
110
+
111
+ interest_rate = 0.05
112
+
113
+ price_mu = 0.01
114
+
115
+ utility_mu = 0.03
116
+
117
+ utility_sigma = 0.3
118
+
119
+
120
+
121
+ theta: float = utility_sigma / math.sqrt(2 * utility_mu)
122
+
123
+ y = lambda u: math.sqrt(1 / (2 * math.pi * theta ** 2)) * math.e ** (- u ** 2 / (2 * theta ** 2))
124
+
125
+
126
+
127
+ def N_t(u_t):
128
+
129
+ iy, err = integrate.quad(y, -np.inf, u_t)
130
+
131
+ userbase = 1 - iy
132
+
133
+ return userbase - math.exp(-(u_t) + math.log(chi / (productivity * beta)) - ((1 - beta) / beta) * math.log((1 - beta) / (interest_rate - price_mu)))
134
+
135
+
136
+
137
+ u_t = optimize.newton(N_t, 0)
138
+
139
+
140
+
141
+ iy, err = integrate.quad(y, -np.inf, u_t)
142
+
143
+ n_t: float = 1 - iy
144
+
145
+
146
+
147
+ print(u_t)
148
+
149
+ print(n_t)
150
+
151
+
152
+
153
+ ```