How Can I Vectorize Linspace In Numpy
I want to do linspace to an array. Just like following: a = np.array([2, 4, 6]) b = vectorize(np.array)(0, a, 5) I would like something back that looks like: b = [[0, 0.5, 1, 1.5,
Solution 1:
Build your own:
def vlinspace(a, b, N, endpoint=True):
a, b = np.asanyarray(a), np.asanyarray(b)
return a[..., None] + (b-a)[..., None]/(N-endpoint) * np.arange(N)
Post a Comment for "How Can I Vectorize Linspace In Numpy"