質問編集履歴
6
指摘点の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -75,8 +75,6 @@
|
|
75
75
|
mesh_x, mesh_y = np.meshgrid(diff_x, diff_y)
|
76
76
|
|
77
77
|
np_integ = (height * mesh_x * mesh_y + constant).ravel()
|
78
|
-
|
79
|
-
np_integ = np_integ.ravel()
|
80
78
|
|
81
79
|
return np_integ
|
82
80
|
|
5
グラフの削除
test
CHANGED
File without changes
|
test
CHANGED
@@ -157,9 +157,3 @@
|
|
157
157
|
center_y:0.01
|
158
158
|
|
159
159
|
constant:304.71
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
fittingしたパラメータでグラフを作成しました(↓↓↓)
|
164
|
-
|
165
|
-
![fitting結果](6d3dd24db77dd208def011fc945d3226.png)
|
4
指摘箇所修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,6 +16,8 @@
|
|
16
16
|
|
17
17
|
|
18
18
|
|
19
|
+
修正後のプログラム
|
20
|
+
|
19
21
|
```python
|
20
22
|
|
21
23
|
import time
|
@@ -24,9 +26,17 @@
|
|
24
26
|
|
25
27
|
from scipy import optimize
|
26
28
|
|
27
|
-
from s
|
29
|
+
from sympy import *
|
28
30
|
|
31
|
+
|
32
|
+
|
33
|
+
a = Symbol('a')
|
34
|
+
|
35
|
+
f = 1/sqrt(2)*exp(-(a**2/2))
|
36
|
+
|
29
|
-
|
37
|
+
F = integrate(f, a)
|
38
|
+
|
39
|
+
func_gauss = lambdify(a, F)
|
30
40
|
|
31
41
|
|
32
42
|
|
@@ -44,16 +54,6 @@
|
|
44
54
|
|
45
55
|
constant = param[4]
|
46
56
|
|
47
|
-
a = Symbol('a')
|
48
|
-
|
49
|
-
f = 1/sqrt(2)*exp(-(a**2/2))
|
50
|
-
|
51
|
-
F = integrate(f, a)
|
52
|
-
|
53
|
-
#func_gaussで不定積分を定義する
|
54
|
-
|
55
|
-
func_gauss = lambdify(a, F)
|
56
|
-
|
57
57
|
#x_list, y_listに範囲内の不定積分を格納する
|
58
58
|
|
59
59
|
#積分する回数を減らすことができる
|
@@ -62,11 +62,19 @@
|
|
62
62
|
|
63
63
|
y_list = [func_gauss((y-cen_y)/sigma) for y in y_range]
|
64
64
|
|
65
|
-
|
65
|
+
#np.diffは前後の差を求める
|
66
66
|
|
67
|
-
#
|
67
|
+
#二次元ガウスの積分値が求まる
|
68
68
|
|
69
|
-
|
69
|
+
diff_x = np.diff(x_list)
|
70
|
+
|
71
|
+
diff_y = np.diff(y_list)
|
72
|
+
|
73
|
+
#np.meshgridで格子座標を生成し、x, yの二次元ガウスの積分値の掛け算を網羅する
|
74
|
+
|
75
|
+
mesh_x, mesh_y = np.meshgrid(diff_x, diff_y)
|
76
|
+
|
77
|
+
np_integ = (height * mesh_x * mesh_y + constant).ravel()
|
70
78
|
|
71
79
|
np_integ = np_integ.ravel()
|
72
80
|
|
@@ -122,7 +130,7 @@
|
|
122
130
|
|
123
131
|
time_1 = time.time()
|
124
132
|
|
125
|
-
optimised_param_2D = optimize.leastsq(residuals_2D, param_2D, args = (actual_data, np_range, np_range, ftol=1.49012e-1, xtol=1.49012e-1, gtol=1.49012e-1, maxfev=4
|
133
|
+
optimised_param_2D = optimize.leastsq(residuals_2D, param_2D, args = (actual_data, np_range, np_range, ftol=1.49012e-1, xtol=1.49012e-1, gtol=1.49012e-1, maxfev=40))
|
126
134
|
|
127
135
|
time_2 =time.time()
|
128
136
|
|
@@ -134,21 +142,21 @@
|
|
134
142
|
|
135
143
|
処理時間
|
136
144
|
|
137
|
-
time_2 - time_1 =
|
145
|
+
time_2 - time_1 = 0.007936954498291016
|
138
146
|
|
139
147
|
|
140
148
|
|
141
149
|
fitting結果
|
142
150
|
|
143
|
-
height:1943.
|
151
|
+
height:1943.76
|
144
152
|
|
145
153
|
sigma:0.31
|
146
154
|
|
147
|
-
center_x:0.
|
155
|
+
center_x:-0.41
|
148
156
|
|
149
|
-
center_y:
|
157
|
+
center_y:0.01
|
150
158
|
|
151
|
-
constant:304.
|
159
|
+
constant:304.71
|
152
160
|
|
153
161
|
|
154
162
|
|
3
指摘を参考に変更を加えた
test
CHANGED
File without changes
|
test
CHANGED
@@ -58,29 +58,13 @@
|
|
58
58
|
|
59
59
|
#積分する回数を減らすことができる
|
60
60
|
|
61
|
-
x_list = []
|
61
|
+
x_list = [func_gauss((x-cen_x)/sigma) for x in x_range]
|
62
62
|
|
63
|
-
y_list = []
|
63
|
+
y_list = [func_gauss((y-cen_y)/sigma) for y in y_range]
|
64
64
|
|
65
|
-
for x in x_range:
|
66
|
-
|
67
|
-
x_list.append(func_gauss((x-cen_x)/sigma))
|
68
|
-
|
69
|
-
for y in y_range:
|
70
|
-
|
71
|
-
y_list
|
65
|
+
integ_list = [height * (x_list[i+1] - x_list[i]) * (y_list[j+1] - y_list[j]) + constant for i in range(len(x_list)-1) for j in range(len(y_list)-1)]
|
72
|
-
|
73
|
-
integ_list = []
|
74
66
|
|
75
67
|
#不定積分に積分したい範囲を代入して積分値を求める
|
76
|
-
|
77
|
-
for i in range(len(x_list)-1):
|
78
|
-
|
79
|
-
for j in range(len(y_list)-1):
|
80
|
-
|
81
|
-
integ_result = height * (x_list[i+1] - x_list[i]) * (y_list[j+1] - y_list[j]) + constant
|
82
|
-
|
83
|
-
integ_list.append(integ_result)
|
84
68
|
|
85
69
|
np_integ = np.array(integ_list)
|
86
70
|
|
@@ -138,7 +122,7 @@
|
|
138
122
|
|
139
123
|
time_1 = time.time()
|
140
124
|
|
141
|
-
optimised_param_2D = optimize.leastsq(residuals_2D, param_2D, args = (actual_data, np_range, np_range))
|
125
|
+
optimised_param_2D = optimize.leastsq(residuals_2D, param_2D, args = (actual_data, np_range, np_range, ftol=1.49012e-1, xtol=1.49012e-1, gtol=1.49012e-1, maxfev=4、))
|
142
126
|
|
143
127
|
time_2 =time.time()
|
144
128
|
|
2
文章の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -168,6 +168,6 @@
|
|
168
168
|
|
169
169
|
|
170
170
|
|
171
|
-
fittingしたパラメータでグラフを作成した
|
171
|
+
fittingしたパラメータでグラフを作成しました(↓↓↓)
|
172
172
|
|
173
173
|
![fitting結果](6d3dd24db77dd208def011fc945d3226.png)
|
1
初心者マーク、説明の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -166,4 +166,8 @@
|
|
166
166
|
|
167
167
|
constant:304.8
|
168
168
|
|
169
|
+
|
170
|
+
|
171
|
+
fittingしたパラメータでグラフを作成した
|
172
|
+
|
169
173
|
![fitting結果](6d3dd24db77dd208def011fc945d3226.png)
|