mps9506 / mann-kendall-trend Goto Github PK
View Code? Open in Web Editor NEWSimple python function to run Mann-Kendall Test for Trend
License: MIT License
Simple python function to run Mann-Kendall Test for Trend
License: MIT License
Add BSD license to make compatible with scipy: https://github.com/scipy/scipy/blob/master/LICENSE.txt
Hi,
When running the MK function I am getting an error message on some datasets:
test_trend,h,p,z = mk_test(ts,alpha=0.05)
File "C:/Python/Anaconda/SA_Water/TrendTest_rainfall_seasonal_data.py", line 107, in mk_test
tp[i] = sum(unique_x[i] == x)
File "C:\Python\Anaconda\lib\site-packages\pandas\core\ops.py", line 741, in wrapper
if len(self) != len(other):
TypeError: len() of unsized object
Any ideas what this is about?
When it runs it is brilliant!!
Regards,
Darren
Compared to http://vsp.pnnl.gov/help/Vsample/Design_Trend_Mann_Kendall.htm, the code is adding the term for tied values instead of substracting it.
I can do a pull-request if necessary.
could be implemented with a numpy trick:
s = np.sum(np.sign(np.tril(np.subtract.outer(a,a)))) # sum of sign(xi-xj) where i>j
Hi,
Are there any plans to implement the algorithm to calculate the number of samples required to detect a trend? As per the relevant section in http://vsp.pnnl.gov/help/Vsample/Design_Trend_Mann_Kendall.htm.
If not, then I'd be happy to attempt a PR.
Thanks.
If null hypothesis = data comes from population with independent realizations and are identically distributed, the alternative hypothesis is that the data follows a monotonic trend. This is calculated with the two tailed test and currently implemented in the script.
However, if the alternative is indeed an "increasing trend" or "decreasing trend" (as currently returned in the script) p values should be calculated with the single tail of the distribution.
See:
Implementation in the trend package in R.
Suggest adding an argument for users to specify the alternative.
Thanks to Moshe Elitzur for identifying this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.