From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

3 points AutoCorrelation

Hi,

   I am doing calculation of autocorrelation on a set of 4000 points time series dataset.

   Labview has a build-in autocorrelation function which is for 2 points, see attached picture 1.

   Now I wish to do 3 or 4 points autocorrelation on this dataset, see attached picture 2. I tried the silly method-nested for loop, see attached VI in LabView8.6.1, but it is very slow. Is there any good recipe for this calculation?

   Thanks.

 

Wei

0 Kudos
Message 1 of 8
(2,847 Views)

Hi Wei,

 

 

Is this the info that your looking for?

TN
Currently using LV 8.5
logo
0 Kudos
Message 2 of 8
(2,835 Views)

Hi wei,

 

probably there's a better recipe then yours Smiley Wink

 

I didn't change your algorithm, but cleaned up for LabView.

You should:

- remove constant values/operations out of loops/structures

- let LV do the tricky stuff (IndexArray gives back zero automatically, when index is out of range...)

- simplify (AddArray function instead of shiftregister+add function)

- do you really want to normalize the sum in each iteration??? Usually you normalize the scalar values before addition... (which again could be done by autoindexing/AddArray)

- avoid locals, even more in loops

- avoid sequence structures, especially when used just for hiding code...

- avoid (graph) indicators like "correlation R(t)" in loops when aiming for max speed!

 

You should check the 2D Correlation as suggested if it fits your needs.

Or do the calculations on "vectors", a sum(Xmn * Xjn * Xjm) can be done easily by multiplying and adding arrays in LabView...

Message Edited by GerdW on 07-29-2009 11:50 AM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 8
(2,830 Views)

Hi, THN,

     Thanks for your reply.

     I know the AutoCorrelation function in LabVIEW. But it is for 2 points calculation(both 1D and 2D


THN wrote:

Hi Wei,

 

 

Is this the info that your looking for?


 

).

 

Best regards,

Wei

0 Kudos
Message 4 of 8
(2,813 Views)

Hi GerdW,

    Thank you very much. Your suggestion looks very helpful.

    I am thinking about it.

    The 2D AutoCorrelation works for 2-points, too.

    By the way, why to avoid the sequence structures which is used very often?

 

Best regards,

Wei


GerdW wrote:

Hi wei,

 

probably there's a better recipe then yours Smiley Wink

 

I didn't change your algorithm, but cleaned up for LabView.

You should:

- remove constant values/operations out of loops/structures

- let LV do the tricky stuff (IndexArray gives back zero automatically, when index is out of range...)

- simplify (AddArray function instead of shiftregister+add function)

- do you really want to normalize the sum in each iteration??? Usually you normalize the scalar values before addition... (which again could be done by autoindexing/AddArray)

- avoid locals, even more in loops

- avoid sequence structures, especially when used just for hiding code...

- avoid (graph) indicators like "correlation R(t)" in loops when aiming for max speed!

 

You should check the 2D Correlation as suggested if it fits your needs.

Or do the calculations on "vectors", a sum(Xmn * Xjn * Xjm) can be done easily by multiplying and adding arrays in LabView...

Message Edited by GerdW on 07-29-2009 11:50 AM

 

0 Kudos
Message 5 of 8
(2,812 Views)

HI,

   I tried the 2-points autocorrelation calculation on matrix. But it is said "Not enough memory to complete this Operation".

   My computer: Intel Quad CPU Q9400, 3.37GB memory, windows XP pro sp3.

   See attached program and data file (4000 data points). The matrix size would be 8000X4000.

 

Thanks,

 

Best,

Wei 

Message Edited by weitong on 07-30-2009 01:31 AM
Download All
0 Kudos
Message 6 of 8
(2,796 Views)

Hi Wei,

 

with "avoid locals" I didn't meant to use "value" property nodes - they are even worse than locals...

 

See the attachment, now without locals. It runs on my computer with only 1GB of RAM (vi needs ~256MB for data using your csv file)!

 

Edited:

Sequence structures are most of the time use- and senseless with LabView. They only hide code and are most often needed when programming in a non-LabView-style (like avoiding race conditions when using locals). Sequence disable parallel processing - and that's their only use in LabView...

Message Edited by GerdW on 07-30-2009 09:08 AM
Message Edited by GerdW on 07-30-2009 09:09 AM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 8
(2,789 Views)

Hi, GerdW,

    Thanks a lot. I really learned a lot from you.

    Yes, it runs perfect after I restarted my computer.

    I realized the calculation of 2 points autocorrelation through matrix multiplication which is fast as you see.

    But, I am still confused how to convert the sum for 3 points autocorrelation to a matrix form.

 

 

 

Best regards,

 

Wei

Message Edited by weitong on 07-30-2009 07:10 AM
Message Edited by weitong on 07-30-2009 07:12 AM
0 Kudos
Message 8 of 8
(2,779 Views)