如何以指数方式对一维数组 numpy 数组进行下采样
How to downsample a 1d array numpy array exponentially
我有一个一维 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)
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)
我用的是log base 10,你可以改成natural。
我有一个一维 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)
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)
我用的是log base 10,你可以改成natural。