Home > OS >  Linspace in python?
Linspace in python?

Time:09-09

So I recently saw a post use linspace in Python, is this not a Matlab function? I cannot find it in the docs and was under the impression that the Python alternative for linspace is range. Is it part of some module/library/package?

CodePudding user response:

i invite you to check this post! Short answer however is : it's not integrated directly, you have to import numpy.

CodePudding user response:

As Bylal said it's a numpy thing. Numpy mostly exists for greater easy of use and performance in mathematical functions. While you can achieve the same thing as linspace with a list comprehension of a range linspace is less verbose and much faster (plus for mathematical/scientific applications numpy's arrays are far easier to work with than python's lists and sets).

Most of what numpy does is relatively easily done in regular python code but numpy is far faster and much easier to work with.

  • Related