In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "how to achieve MK inspection in Python". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
MK test: time series to detect and find out the mutation point, this paper refers to the matlab program on the Internet and rewrites the python code as follows:
Import numpy as npimport pandas as pdimport matplotlib.pyplot as plt# reads time series data data = pd.read_csv ('') # defines time and runoff data column x = list (range (len (data) y = data.to_list# acquires sample data n = len (y) # positive sequence calculation # defines cumulative quantity series Sk, length n, initial value is 0Sk = np.zeros (n) UFk = np.zeros (n) # defines Sk series element ss = 0Secreti starting at 2 According to the UFk formula of statistics, Sk (1), E (1) and Var (1) are all 0 when iTun1, so UFk is meaningless, so in the formula Let UFk (1) = 0for i in range (2Powern): for j in range (1Magi): if y [I] > y [j]: s + = 1 Sk [I] = s E = I * (I-1) / 4 Var = I * (I-1) * (2 * I + 5) / 72 UFk [I] = (Sk [I]-E) / np.sqrt (Var) # inverse sequence y2 is constructed Length is n, initial value is inverse cumulant series Sk2, length n, initial value is inverse statistic series Sk2, length n, initial value is 0y2 = np.zeros (n) Sk2 = np.zeros (n) UBk = np.zeros (n) # s return to zero s = inverse sample y2 = y [::-1] # I starts from 2, according to statistics UBk formula Sk (1), E (1), Var (1) are all 0, so UFk is meaningless, so in the formula Let UBk (1) = 0for i in range (2, n): for j in range (1) I): if y2 [I] > y2 [j]: s + = 1 Sk2 [I] = s E = I * (I-1) / 4 Var = I * (I-1) * (2 * I + 5) / 72 UBk [I] =-(Sk2 [I]-E) / np.sqrt (Var) # inverse sequence UBk2 = UBk [::-1] # drawing plt.figure (figsize= (10L5)) plt.plot (range (1) Numb1), UFk,label = 'UFk',color =' orange') plt.plot (range (1, Numb1), UBk2,label = 'UBk',color =' cornflowerblue') plt.ylabel ('UFk-UBk') x_lim = plt.xlim () plt.plot (x_lim, [- 1.96 Lindsay 1.96],' MFLV 'plt.plot (x_lim, [0ZORE0],' mMULICUL') plt.plot (x_lim, [1.96 JL1.96] So much for the introduction of "how to implement MK checking by Python" plt.show () Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.