Python Scipy科學計算學習筆記
1 min readSep 7, 2019
參考資料
資料分析與視覺化 ( 5 )-資料好幫手 Pandas 與 Scipy 基本操作
安裝
pip install scipy
線性代數
import numpy as np
from scipy import linalg
# 解二元一次線性方程式
# 2x + 2y = 5
# 4x + 3y = 6
# 係數
A = np.array([[2,2],[4,3]])
# 答案
B = np.array([[5],[6]])
# 解方程式
ans = linalg.solve(A,B)
"answer: x=%s, y=%s" % (ans[0][0], ans[1][0])
積分
from scipy import integrate
# 對 x 三次方從 0 到 2 進行定積分
ans= integrate.quad(lambda x: x**3, 0,2)
ans[0]
傅立葉轉換
from scipy.fftpack import fft, ifft
x = np.array([1.0, 1.5, 1.0, -1.0, 1.5])
y = fft(x)
y