Skip to content

Instantly share code, notes, and snippets.

@humamfauzi
Created July 20, 2018 06:25
Show Gist options
  • Save humamfauzi/10c17689377e2b7dd087c6bb0977a7c0 to your computer and use it in GitHub Desktop.
Save humamfauzi/10c17689377e2b7dd087c6bb0977a7c0 to your computer and use it in GitHub Desktop.
Approximating distribution in an array.
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