0

I am attempting to convert the Fourier transform of a Pearson correlation from C++ to Python. However, I'm failing to understand the smoothing technique used.

The 2D array R is initialised as shown below. The array is then assigned the smoothed values of the transformed correlation values, SqSum.

double[,] R = new double[70,2];



for(int Period = 8; Period <= 48; Period++)

{

R[Period, 1] = R[Period, 0]; 

R[Period, 0] = 0.2 * SqSum[Period] * SqSum[Period] + 0.8 * R[Period,1];                 

}               

How is this smoothing being performed? If on every iteration of the for loop, R[Period, 1] is being assigned the value of R[Period, 0], which I assume to be 0, should R[Period, 0] just become 0.2 * SqSum[Period] * SqSum[Period]?

Sorry if this is a basic question but any help in my understanding is appreciated, cheers.

User415
  • 11
  • 2
  • Your assumption is only true the first time. This is presumably executed multiple times, and the next time `R[Period, 0]` will contain the result of this code, and each time will build on the previous one. – Barmar Sep 11 '19 at 22:18
  • This code doesn't look like C++. I don't think it allows declaring 2D arrays like that. – Barmar Sep 11 '19 at 22:21
  • See https://stackoverflow.com/questions/936687/how-do-i-declare-a-2d-array-in-c-using-new for how you create a 2D array dynamically in C++. – Barmar Sep 11 '19 at 22:21
  • You would need more code (more context) to see how the smoothing is performed. However, before asking for a [mcve], I would ask which question do you want answered? 1) How does the Python code work? *or* 2) How to implement this in C++? – JaMiT Sep 11 '19 at 23:40

0 Answers0