2021年3月24日星期三

Variable array creation using numpy operations

I wish to create a variable array of numbers in numpy while skipping a chunk of numbers. For instance, If I have the variables:

m = 5    k = 3    num = 50  

I want to create a linearly spaced numpy array starting at num and ending at num - k, skip k numbers and continue the array generation. Then repeat this process m times. For example, the above would yield:

np.array([50, 49, 48, 47, 44, 43, 42, 41, 38, 37, 36, 35, 32, 31, 30, 29, 26, 25, 24, 23])  

How can I accomplish this via Numpy?

https://stackoverflow.com/questions/66790100/variable-array-creation-using-numpy-operations March 25, 2021 at 06:05AM

没有评论:

发表评论