Created
July 20, 2018 06:25
-
-
Save humamfauzi/10c17689377e2b7dd087c6bb0977a7c0 to your computer and use it in GitHub Desktop.
Approximating distribution in an array.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def approx_distribution(array): | |
array = np.array(array) | |
array.sort() | |
radii = np.std(array) | |
array_size = len(array) | |
max_val = np.max(array) | |
min_val = np.min(array) | |
container = np.zeros(array_size) | |
count = 0 | |
for i in np.linspace(min_val + radii, max_val - radii, array_size): | |
container[count] = len(array[np.where((array > i - radii) & (array < i + radii))]) | |
count += 1 | |
return container |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment