![]() |
Winsorized Mean and Standard Deviation - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Winsorized Mean and Standard Deviation (/thread-28258.html) |
Winsorized Mean and Standard Deviation - Wheeliam - Jul-11-2020 Hi all, ![]() I have a slight problem. I need to winsorize the means and standard deviations in my code. The code is a modification of what I have bumped into online (with a few add-ons and corrections). The mean is denoted as: e = numpy.mean( r ) ps. I have added spaces between brackets and r - cos it was changing it to r in circle How would I go about winosrizing it? Here is an article on how to deal with this issue, although given how new I am to Python, I would need someone's guidance in implementation. https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.mstats.winsorize.html The only other instance of the "mean" I have in my code is when I calculate Information Ratio: def information_ratio(returns, benchm): diff = returns - benchmark return numpy.[b]mean[/b](diff) / vol(diff)Furthermore, would the same methodology (as for the winosrized mean) apply to the standard deviation (winsorizing it)? Again, the only instance of the standard deviation I have listed in my code is: return numpy.std(returns)Please advise. Thank you |