Trimmed Mean with Percentage Limit in Python?
Question: I am trying to calculate the **trimmed mean** , which excludes the outliers,
of an array.

I found there is a module called
[`scipy.stats.tmean`](http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.tmean.html#scipy.stats.tmean),
but it requires the user specifies the **range by absolute value instead of
percentage values**.

In Matlab, we have [`m =
trimmean(X,percent)`](http://www.mathworks.com/help/stats/trimmean.html), that
does exactly what I want.

**Do we have the counterpart in Python?**


Answer: At least for scipy v0.14.0, there is a dedicated (but undocumented?) function
for this:

    
    
    from scipy import stats
    m = stats.trim_mean(X, 0.1) # Trim 10% at both ends
    

which used
[`stats.trimboth`](http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.trimboth.html)
inside.

