# CLX Periodicity Analysis

## Introduction

Periodicity is a crucial concept in understanding time-series data in various fields. Periodicity detection discovers recurring patterns at specific intervals.

Time series data is often noisy and requires transformation into a different domain to identify the fundamental frequencies.

Knowing the periodicity of time-series data is useful for supply chain management, anomaly detection in many industries, including retail and cyber.

## How to use CLX Periodicity Detection

[1]:

import cudf

# Input sample
signal = cudf.Series([3274342, 3426017, 3758781, 3050763, 3765678, 3864117, 3287878,
3397645, 3509973, 3844070, 3725934, 3287715, 3373505, 3909898,
3630503, 3070180, 3528452, 3801183, 3277141, 3625685, 3142354,
3140470, 3829668, 3623178, 3129990, 3549270, 3928100, 3331894,
3599137, 3978103, 3471284, 3220011, 3654968, 3789411, 3584702,
3512986, 3401678, 3774912, 3461276, 3549195, 3320150, 3655766,
3562267, 3525937, 3267010, 3441179, 3596828, 3208453, 3167370,
4036471, 3358863, 3169950, 3341009, 4010556, 3317385, 3132360,
3753407, 3808679, 3499711, 3248874, 3945531, 3837029, 3400068,
3625813, 3612960, 3523530, 3427957, 3749848, 3475452, 3289964,
3238560, 3428817, 3489523, 3429917, 3557773, 3432514, 3459938,
3440332, 3296710, 3711087, 3729805, 3447954, 3773181, 3855161,
3955022, 3252652, 3599792, 3769181, 3809061, 3495044, 3396623,
3680456, 3358306, 3368779, 3469016, 3169477, 3449529, 3738450,
3293116, 3303107, 3522923, 3746871, 3436093, 3124102, 3679797,
3829441, 3641894, 3654410, 3588528, 3628979, 3738718, 3737379,
3370349, 3583376, 3694398, 3559319, 3464402, 3421738, 3265208])


CLX periodicity detection module to get the periodogram for our signal. The to_periodgram function standardizes the signal, applies the Discrete Fourier Transform, and returns the periodogram.

[2]:

import clx.analytics.periodicity_detection as pdd

periodogram = pdd.to_periodogram(signal)


Now we choose the confidence ratio using filter_periodogram feature. Confidence in this case is 99.9.% hence $p$ will be used as 0.001.

[3]:

periodogram = periodogram[:int((len(signal)/2))]
periodogram = pdd.filter_periodogram(periodogram, 0.001)


## How to reconstruct the signal in the time domain

To asses the periodicities found from the previous step we can use iFFT on the periodogram to find the autocorrelation function because our signal is real valued. We can easily accomplish this by passing the periodogram to CLX’s to_time_domain function.

[4]:

reconstructed = pdd.to_time_domain(periodogram)
reconstructed

[4]:

array([0.26389302, 0.25470949, 0.22783294, 0.18526557, 0.13035481,
0.06865704, 0.02978938, 0.08107234, 0.14211096, 0.19489424,
0.23454643, 0.25800256, 0.26352351, 0.25070444, 0.22048766,
0.17513786, 0.11830457, 0.05657488, 0.03572989, 0.09357597,
0.15352238, 0.20399289, 0.24060791, 0.26057394, 0.26241606,
0.24599927, 0.21253286, 0.16454466, 0.10602009, 0.04528412,
0.04528412, 0.10602009, 0.16454466, 0.21253286, 0.24599927,
0.26241606, 0.26057394, 0.24060791, 0.20399289, 0.15352238,
0.09357597, 0.03572989, 0.05657488, 0.11830457, 0.17513786,
0.22048766, 0.25070444, 0.26352351, 0.25800256, 0.23454643,
0.19489424, 0.14211096, 0.08107234, 0.02978938, 0.06865704,
0.13035481, 0.18526557, 0.22783294, 0.25470949])


For in-depth example of Periodicity Analysis view this Jupyter Notebook.