我有一個一維 numpy 陣列,我想用指數分布對其進行下采樣。目前,我正在使用 signal.resample(y,downsize) 進行統一的重新采樣。不確定是否有一種快速的方法可以做到這一點,但成倍增加

from scipy import signal
# uniform resample example
x = np.arange(100)
y = np.sin(x)
linear_resample = signal.resample(y,15)
uj5u.com熱心網友回復:
import numpy as np
np.random.seed(73)
# a random array of integers of length 100
arr_test = np.random.randint(300, size=100)
print(arr_test)
# lets divide 0 to 100 in exponential fashion
ls = np.logspace(0.00001, 2, num=100, endpoint=False, base=10.0).astype(np.int32)
print(ls)
# sample the array
arr_samp = arr_test[ls]
print(arr_samp)
我使用了以 10 為底的對數。如果需要,您可以更改為自然。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/436255.html
下一篇:從兩個numpy陣列制作字典
