物理学会2025@広島大学
物理学会に参加してきました。サッカーもできて、いろいろな人と打ち合わせもでき、やはり良い会合だなと思いました。 オンサイトは年一回なので、記憶に残りやすいです。
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
def fun(t, a, b, tau):
return a * np.sin(b * t) * np.exp(- t * tau)
dp = 300
x = np.arange(dp)
ra = 0.05 * np.random.randn(dp)
y = fun(x, 1, 0.03, 0.008)+ ra
popt, pcov = curve_fit(fun, x, y, bounds = ([0.8, 0.02, 0.005], [1.2, 0.04, 0.01]))
f = plt.figure()
ax = f.add_axes([0.2, 0.2, 0.6, 0.6])
ax.plot(x, y, marker = '.', markersize = 2, linestyle = '', color = [0, 0, 0], label = 'raw data')
ax.plot(x, fun(x, *popt), 'r-', linewidth = 2, label = 'curve_fit')
print(popt)
ax.legend()
[0.96882364 0.03010141 0.00778967]
<matplotlib.legend.Legend at 0x7fa2780d8a90>
コメント
コメントを投稿