Skip to content

Instantly share code, notes, and snippets.

@StuffbyYuki
Created May 22, 2020 01:47
Show Gist options
  • Save StuffbyYuki/6f25f9f2f302cb5c1e82e4481016ccde to your computer and use it in GitHub Desktop.
Save StuffbyYuki/6f25f9f2f302cb5c1e82e4481016ccde to your computer and use it in GitHub Desktop.
Python: Numpy - trim mean function
import numpy as np
def trimmean(arr, percent):
n = len(arr)
k = int(round(n*(float(percent)/100)/2))
return np.mean(arr[k+1:n-k])
@drjasonharrison
Copy link

is arr sorted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment