Python Scipy科學計算學習筆記

參考資料

資料分析與視覺化 ( 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

Written by

Machine Learning / Deep Learning / Python / Flutter cakeresume.com/yanwei-liu

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store