zoukankan      html  css  js  c++  java
  • Numpy API Analysis

    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

     

  • 相关阅读:
    HDU 1348 Wall
    HDU 2202 最大三角形
    HDU 2215 Maple trees
    HDU 1147 Pick-up sticks
    HDU 1392 Surround the Trees
    风语时光
    HDU 1115 Lifting the Stone
    HDU 1086 You can Solve a Geometry Problem too
    HDU 2108 Shape of HDU
    HDU 3360 National Treasures
  • 原文地址:https://www.cnblogs.com/pengpenghappy/p/7095971.html
Copyright © 2011-2022 走看看