I am using scipy stats package to take statistics along the an axis, but I am having trouble taking the percentile statistic using binned_statistic
. I have gen
The problem with the function you defined is that it takes no arguments at all! It needs to take a y
argument that corresponds to your sample, like this:
def percentile10(y):
return(np.percentile(y,10))
You could also use a lambda
function for brevity:
scist.binned_statistic(x, y, statistic=lambda y: np.percentile(y, 10), bins=20,
range=[(0, 5)])[0]