コード例 #1
0
ファイル: example_statutils.py プロジェクト: DrDub/pyradar
# -*- coding: utf-8 -*-

import numpy as np
from pyradar.utils.statutils import compute_cfs
from pyradar.utils.statutils import calculate_pdf_for_pixel
from pyradar.utils.statutils import calculate_cdf_for_pixel
from pyradar.utils.statutils import compute_cdfs
arr = np.array([31, 49, 19, 62, 24, 45, 23, 51, 55, 60, 40, 35,
                54, 26, 57, 37, 43, 65, 18, 41, 50, 56, 4, 54,
                39, 52, 35, 51, 63, 42])
max_value = arr.max()
min_value = arr.min()
start, stop, step = int(min_value), int(max_value + 2), 1

histogram, bin_edge = np.histogram(arr, xrange(start, stop, step))
compute_cfs(histogram)

# >>> array([ 1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
#             1,  2,  3,  3, 3,  3,  4,  5,  5,  6,  6,  6,  6,
#             6,  7,  7,  7,  7,  9,  9, 10, 10, 11, 12, 13, 14,
#            15, 15, 16, 16, 16, 16, 17, 18, 20, 21, 21, 23, 24,
#            25, 26, 26, 26, 27, 27, 28, 29, 29, 30])


calculate_pdf_for_pixel(arr, histogram, bin_edge, 54)
# >>> 0.066666666666666666

calculate_pdf_for_pixel(arr, histogram, bin_edge, 20)
# >>> 0.0

calculate_pdf_for_pixel(arr, histogram, bin_edge, 18)
コード例 #2
0
import numpy as np
from pyradar.utils.statutils import compute_cfs
from pyradar.utils.statutils import calculate_pdf_for_pixel
from pyradar.utils.statutils import calculate_cdf_for_pixel
from pyradar.utils.statutils import compute_cdfs
arr = np.array([
    31, 49, 19, 62, 24, 45, 23, 51, 55, 60, 40, 35, 54, 26, 57, 37, 43, 65, 18,
    41, 50, 56, 4, 54, 39, 52, 35, 51, 63, 42
])
max_value = arr.max()
min_value = arr.min()
start, stop, step = int(min_value), int(max_value + 2), 1

histogram, bin_edge = np.histogram(arr, range(start, stop, step))
compute_cfs(histogram)

# >>> array([ 1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
#             1,  2,  3,  3, 3,  3,  4,  5,  5,  6,  6,  6,  6,
#             6,  7,  7,  7,  7,  9,  9, 10, 10, 11, 12, 13, 14,
#            15, 15, 16, 16, 16, 16, 17, 18, 20, 21, 21, 23, 24,
#            25, 26, 26, 26, 27, 27, 28, 29, 29, 30])

calculate_pdf_for_pixel(arr, histogram, bin_edge, 54)
# >>> 0.066666666666666666

calculate_pdf_for_pixel(arr, histogram, bin_edge, 20)
# >>> 0.0

calculate_pdf_for_pixel(arr, histogram, bin_edge, 18)
# >>> 0.033333333333333333
コード例 #3
0
import numpy as np
from pyradar.utils.statutils import compute_cfs
from pyradar.utils.statutils import calculate_pdf_for_pixel
from pyradar.utils.statutils import calculate_cdf_for_pixel
from pyradar.utils.statutils import compute_cdfs
arr = np.array([31, 49, 19, 62, 24, 45, 23, 51, 55, 60, 40, 35,
                54, 26, 57, 37, 43, 65, 18, 41, 50, 56, 4, 54,
                39, 52, 35, 51, 63, 42])
max_value = arr.max()
min_value = arr.min()
start, stop, step = int(min_value), int(max_value + 2), 1

histogram, bin_edge = np.histogram(arr, xrange(start, stop, step)
compute_cfs(histogram)
>>> array([ 1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
            1,  2,  3,  3, 3,  3,  4,  5,  5,  6,  6,  6,  6,
            6,  7,  7,  7,  7,  9,  9, 10, 10, 11, 12, 13, 14,
           15, 15, 16, 16, 16, 16, 17, 18, 20, 21, 21, 23, 24,
           25, 26, 26, 26, 27, 27, 28, 29, 29, 30])

calculate_pdf_for_pixel(arr, histogram, bin_edge, 54)
>>> 0.066666666666666666
calculate_pdf_for_pixel(arr, histogram, bin_edge, 20)
>>> 0.0
calculate_pdf_for_pixel(arr, histogram, bin_edge, 18)
>>> 0.033333333333333333

calculate_cdf_for_pixel(arr, histogram, bin_edge, 4)
>>> 0.033333333333333333
calculate_cdf_for_pixel(arr, histogram, bin_edge, 50)
>>> 0.59999999999999998