加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

使用numpy.logspace()时出错:如何在对数刻度上生成均匀间隔的数

发布时间:2020-12-16 23:05:22 所属栏目:Python 来源:网络整理
导读:我试图使用numpy.logspace()从1e-10到1e-14生成50个值. http://docs.scipy.org/doc/numpy/reference/generated/numpy.logspace.html import numpy as npx = np.logspace(1e-10,1e-14,num=50)print x 我得到的输出不正确: [ 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1
我试图使用numpy.logspace()从1e-10到1e-14生成50个值.

http://docs.scipy.org/doc/numpy/reference/generated/numpy.logspace.html

import numpy as np
x = np.logspace(1e-10,1e-14,num=50)
print x

我得到的输出不正确:

[ 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.
  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.
  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.  1.]

我还有什么其他选择?

解决方法

>>> import numpy as np
>>> np.logspace(-10,-14,50)
array([  1.00000000e-10,8.28642773e-11,6.86648845e-11,5.68986603e-11,4.71486636e-11,3.90693994e-11,3.23745754e-11,2.68269580e-11,2.22299648e-11,1.84206997e-11,1.52641797e-11,1.26485522e-11,1.04811313e-11,8.68511374e-12,7.19685673e-12,5.96362332e-12,4.94171336e-12,4.09491506e-12,3.39322177e-12,2.81176870e-12,2.32995181e-12,1.93069773e-12,1.59985872e-12,1.32571137e-12,1.09854114e-12,9.10298178e-13,7.54312006e-13,6.25055193e-13,5.17947468e-13,4.29193426e-13,3.55648031e-13,2.94705170e-13,2.44205309e-13,2.02358965e-13,1.67683294e-13,1.38949549e-13,1.15139540e-13,9.54095476e-14,7.90604321e-14,6.55128557e-14,5.42867544e-14,4.49843267e-14,3.72759372e-14,3.08884360e-14,2.55954792e-14,2.12095089e-14,1.75751062e-14,1.45634848e-14,1.20679264e-14,1.00000000e-14])

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读