TransWikia.com

Find periodicity of a signal using python

Data Science Asked by achow on January 9, 2021

I have a dataset that contains occurrences of the Kettle in a single-occupancy house for the duration of a month. In this dataset, ‘ts’ column indicates the unix-timestamp (this can be converted to date and
time) that the kettle was turned ON; and the ‘second’ column indicates the duration in seconds that the kettle was ON.

My requirement – Find routines in the data, evaluate their periodicities and variabilities. For instance, a routine could be “breakfast”, its periodicity might be every day at a certain time and variability might be a time window within the routine occurred.

What I’ve tried and I’m a bit unsure of – I plotted the autocorrelation of the virgin signal with different amounts of lag and found there was no significant correlation with any of its lagged versions. But on looking at the plot of this signal, I see there are peaks every day- morning time. Also, I’ve tried autocorrelation on the denoised(denoised using KNN) version and the under-sampled versions(retaining just first and last samples for each day of the month) and found that the denoised signal also isn’t correlated with its lagged versions, but the under-sampled signal is.

I’m unsure first of all about how to find periodicity of a signal like this, and if the autocorrelation plot lets us make any conclusions about periodicity.

from statsmodels.tsa.stattools import acf
from statsmodels.graphics.tsaplots import plot_acf

# Compute the acf array 
acf_array = acf(q4['seconds'])
print(acf_array)

# Plot the acf function
plot_acf(q4['seconds'],alpha=0.05)
plt.show()

More code showing what I’ve read can be found at – this link.
enter image description here

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP