如何在不指定期间的情况下分解数据中存在多个周期性?
我试图将信号中存在的周期性分解为其各个组件,以计算其时间周期。
说以下是我的示例信号:
t_week = np.linspace(1,480, 480)
t_weekend=np.linspace(1,192,192)
T=96 #Time Period
x_weekday = 10*np.sin(2*np.pi*t_week/T)+10
x_weekend = 2*np.sin(2*np.pi*t_weekend/T)+10
x_daily_weekly_sinu = np.concatenate((x_weekday, x_weekend))
#Creating the Signal
x_daily_weekly_long_sinu = np.concatenate((x_daily_weekly_sinu,x_daily_weekly_sinu,x_daily_weekly_sinu,x_daily_weekly_sinu,x_daily_weekly_sinu,x_daily_weekly_sinu,x_daily_weekly_sinu,x_daily_weekly_sinu,x_daily_weekly_sinu,x_daily_weekly_sinu))
#Visualization
plt.plot(x_daily_weekly_long_sinu)
plt.show()
-
-
- 周期
如下所示:
我尝试使用STATSMODEL中的STL分解方法:
sm.tsa.seasonal_decompose()
但是,只有在您事先知道该周期的情况下,这是合适的。并且仅适用于一次分解一个周期。 虽然,我需要分解任何具有多个周期性的信号,并且其周期未知。
谁能帮助如何实现这一目标?
I am trying to decompose the periodicities present in a signal into its individual components, to calculate their time-periods.
Say the following is my sample signal:
You can reproduce the signal using the following code:
t_week = np.linspace(1,480, 480)
t_weekend=np.linspace(1,192,192)
T=96 #Time Period
x_weekday = 10*np.sin(2*np.pi*t_week/T)+10
x_weekend = 2*np.sin(2*np.pi*t_weekend/T)+10
x_daily_weekly_sinu = np.concatenate((x_weekday, x_weekend))
#Creating the Signal
x_daily_weekly_long_sinu = np.concatenate((x_daily_weekly_sinu,x_daily_weekly_sinu,x_daily_weekly_sinu,x_daily_weekly_sinu,x_daily_weekly_sinu,x_daily_weekly_sinu,x_daily_weekly_sinu,x_daily_weekly_sinu,x_daily_weekly_sinu,x_daily_weekly_sinu))
#Visualization
plt.plot(x_daily_weekly_long_sinu)
plt.show()
My objective is to split this signal into 3 separate isolated component signals consisting of:
- Days as period
- Weekdays as period
- Weekends as period
Periods as shown below:
I tried using the STL decomposition method from statsmodel:
sm.tsa.seasonal_decompose()
But this is suitable only if you know the period beforehand. And is only applicable for decomposing a single period at a time.
While, I need to decompose any signal having multiple periodicities and whose periods are not known beforehand.
Can anyone please help how to achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过更多的算法方法?我们可以首先尝试确定信号的变化,即振幅或频率。在发生重大变化的地方确定所有阈值点,并在该窗口上进行FFT。
这是我的方法:
请注意,您有多种方法可以解决这个问题。我想说的是,从小波变换开始,就一个很好的开端。
这是代码,尝试添加一些高斯噪声或其他可变性以对其进行测试。您会看到噪音越多,您的dwt的最小epsilon就越高,因此您需要调整其中的一些。
用您的示例打印以下示例(注意结果并不精确)。
请注意,这就是DWT COEFS的外观。

Have you tried more of an algorithmic approach? We could first try to identify the changes in the signal, either amplitude or frequency. Identify all threshold points where there is a major change, with some epsilon, and then do FFT on that window.
Here was my approach:
Note there are many ways you could mess with this. I would say starting with a wavelet transform, personally, is a good start.
Here is the code, try adding some Gaussian noise or other variability to test it out. You see the more noise the higher your min epsilon for DWT will need to be so you do need to tune some of it.
With your example that printed the following (note results weren't exact).
Note this is what the DWT coefs look like.
