That being said, the real cepstrum of a time series can be calculated by
the inverse Fourier transform of the real logarithm of the Fourier transform of the time–series (K. Kalpakis et al., 2001).
Let’s assume that we have the following time series:
using YFinance
series = get_prices("MSFT", startdt="2021-01-01", enddt="2021-01-20")["adjclose"]
# 11-element Vector{Float64}:
# 211.99659729003906
# 212.20114135742188
# 206.69886779785156
# 212.5809326171875
# 213.87611389160156
# 211.80184936523438
# 209.30877685546875
# 210.6819305419922
# 207.44874572753906
# 207.0884246826172
# 210.779296875
Now, I want to calculate the real cepstrum of this time series. According to the definition brought earlier, the following steps should be taken:
- Calculate the Fourier transform of the time series.
- Calculate the real logarithm of the result of 1st step.
- Take the inverse Fourier transform of the result of 2nd step.
So, the process can be fused as follows:
using FFTW
series |> fft .|> real .|> log |> ifft
# ERROR: DomainError with -2.1316965395989245:
# log was called with a negative real argument but will only return a complex result if called with a complex argument. Try log(Complex(x)).
So, there is a mathematical problem that can be handled as mentioned in the description of the error:
series |> fft .|> real .|> Complex .|> log |> ifft
# 11-element Vector{ComplexF64}:
# 2.1053213005396554 + 1.71359599286716im
# 0.5250627554737464 - 0.4415937871666108im
# 0.3054836751101531 + 0.6365173493037021im
# 0.5006638565965567 + 0.025177272226508857im
# 0.8459161100203939 - 0.6848321808959316im
# 0.643679369835847 - 0.3920666499012487im
# 0.643679369835847 - 0.3920666499012487im
# 0.8459161100203939 - 0.6848321808959316im
# 0.5006638565965567 + 0.025177272226508857im
# 0.3054836751101531 + 0.6365173493037021im
# 0.5250627554737464 - 0.4415937871666108im
However, I have a series of Complex values. Then, what are the real cepstrums? Are they the real part of the values? Although, these questions are valid if I have done the procedure correctly.