user3408085
user3408085

Reputation: 130

Function to create a non equally spaced array in numpy

I would like to create an array with the form [1, 2, 4, 8, 16, 32, ...]. Not always with that spacing between numbers.

Is there a linspace/arange type function which allows me to create vector of non equally spaced numbers?

Thanks

Upvotes: 1

Views: 1343

Answers (1)

Edward Khachatryan
Edward Khachatryan

Reputation: 469

Yes, there is also logspace and geomspace in NumPy.

np.geomspace(1,32,6) gives you array([ 1., 2., 4., 8., 16., 32.])

Upvotes: 4

Related Questions