In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how Python lags eigenvalues by one line. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
What is the lead-lag correlation
If you want to see whether the two time series are related, the simplest way is to find the correlation coefficient, but in the study of atmosphere, ocean and other scientific problems, the response of a process is often not real-time. It is possible that the a process will only occur after a period of time, and this relationship is often not represented by the correlation coefficient of the same period.
Lead-lag correlation is to see whether the occurrence and evolution of the two processes have a certain correlation in time.
For example:
There are two time series an and b, both of which are twelve months in length. The direct calculation of the correlation coefficient is a simple simultaneous correlation.
If the correlation coefficient of January-November of a to the February-December of b is the correlation of a to b one month ahead, and the correlation of February-December of a to b from January to November is called the lag correlation of a to b, and so on, the lead lag correlation of n months can be obtained, and the drawing shows the positive and negative n months along the month of October (the same period).
Implementation in python
Two time series need to be input, and the result is the sequence of lead-lag correlation coefficient of data1 to data2.
From scipy.stats import pearsonrimport numpy as np # lead lag correlation def leadlagcor (data1,data2,n): # data1 and data2 are two time series, n sets the number of time steps to do with lead lag a c=b*2+1 x=np.arange (- n journal 1) r=np.zeros ((c)) p=np.zeros ((c)) for i in range (c): if I
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.