首页 > 后端开发 > Python教程 > Numpy API Analysis

Numpy API Analysis

PHP中文网
发布: 2017-06-30 09:22:32
原创
1272 人浏览过

histogram

 

>>> a = numpy.arange(5)

>>> hist, bin_edges = numpy.histogram(a,density=False)

>>> hist, bin_edges

(array([1, 0, 1, 0, 0, 1, 0, 1, 0, 1], dtype=int64), array([ 0. , 0.4, 0.8, 1.2, 1.6, 2. , 2.4, 2.8, 3.2, 3.6, 4. ]))

 

Analysis:

  • Variable a is [0 1 2 3 4]
  • After call histogram, it will calculate the total count each number in a= [0 1 2 3 4] according to each bins(阈值), for example:

bins

Contains number

result

[0.-0.4)

0

1

[0.4-0.8)

N/A

0

[0.8-1.2)

1

1

[1.2-1.6)

N/A

0

[1.6-2.)

N/A

0

[2.-2.4)

2

1

[2.4-2.8)

N/A

0

[2.8-3.2)

3

1

[3.2-3.6)

N/A

0

[3.6-4.]

4

1


[0.-0.4) contains 0, so result is 1

[0.4-0.8) does not contain any number in [0 1 2 3 4], so result is 0
[0.8-1.2) contains 1, so result is 1
[1.2-1.6) does not contain any number in [0 1 2 3 4], so result is 0
[1.6-2.) does not contain any number in [0 1 2 3 4], so result is 0

[2.-2.4) contains 2, so result is 1

[2.4-2.8) does not contain any number in [0 1 2 3 4], so result is 0

[2.8-3.2) contains 3, so result is 1

[3.2-3.6) does not contain any number in [0 1 2 3 4], so result is 0

[3.6-4.] contains 4, so result is 1

 

以上是Numpy API Analysis的详细内容。更多信息请关注PHP中文网其他相关文章!

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板