# HG changeset patch # User Nicolas Saunier # Date 1403067175 14400 # Node ID 0c86c73f3c0975ce89ac8f9c0953767fead1f52c # Parent 47d9970ee9548a53fb1f36de8e643ae7ea2cabf9 median smoothing diff -r 47d9970ee954 -r 0c86c73f3c09 python/utils.py --- a/python/utils.py Fri Jun 06 17:51:10 2014 -0400 +++ b/python/utils.py Wed Jun 18 00:52:55 2014 -0400 @@ -203,6 +203,11 @@ else: return 0. +def medianSmoothing(x, X, Y, halfwidth): + '''Returns the media of Y's corresponding to X's in the interval [x-halfwidth, x+halfwidth]''' + from numpy import median + return median([y for observedx, y in zip(X,Y) if abs(x-observedx)