Difference in output between numpy linspace and numpy logspace

后端 未结 4 1807
梦毁少年i
梦毁少年i 2021-01-04 04:46

Numpy linspace returns evenly spaced numbers over a specified interval. Numpy logspace return numbers spaced evenly on a log scale.

I don\'t understand why numpy log

4条回答
  •  长情又很酷
    2021-01-04 05:15

    2017 update: The numpy 1.12 includes a function that does exactly what the original question asked, i.e. returns a range between two values evenly sampled in log space.

    The function is numpy.geomspace

    >>> np.geomspace(0.02, 2.0, 20)
    array([ 0.02      ,  0.0254855 ,  0.03247553,  0.04138276,  0.05273302,
            0.06719637,  0.08562665,  0.1091119 ,  0.13903856,  0.17717336,
            0.22576758,  0.28768998,  0.36659614,  0.46714429,  0.59527029,
            0.75853804,  0.96658605,  1.23169642,  1.56951994,  2.        ])
    

提交回复
热议问题