0

I have a 1-d numpy array which I would like to down sample with a exponential distribution. Currently, I am using signal.resample(y,downsize) for a uniform re-sample. Not sure if there is a quick way to do this but exponentially

enter image description here

from scipy import signal

# uniform resample example
x = np.arange(100)    
y = np.sin(x)
linear_resample = signal.resample(y,15)

1 Answer 1

1
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)

I have use log base 10. You can change to natural if you want.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.