gpt4 book ai didi

python :使用 numpy.histogram

转载 作者:太空宇宙 更新时间:2023-11-03 13:24:15 26 4
gpt4 key购买 nike

我正在使用这个:

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

我有一个列表a,我想这样使用:

numpy.histogram(a,bins=[0.1,0.2,0.3,0.4...6], range=[0:6])
  1. 如何在 0.1 间隔内包含一组从 0.1 到 6 的 bin?
  2. 如何指定 0 到 6 的范围?

最佳答案

也许您正在寻找 np.linspace(0,6,num=61)np.arange(0,6.1,0.1):

import numpy as np
a=np.random.random(100)*6
hist=np.histogram(a,bins=np.linspace(0,6,num=61))

关于 python :使用 numpy.histogram,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3399210/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com