LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Difference between StdDev() and ACDCEstimator()

Hello,

What is the difference between StdDev() and ACDCEstimator()?
What is the formula used to calculate the ac and dc part in the
ACDCEstimator() function?

Thanks,
Yannick Willener
0 Kudos
Message 1 of 3
(3,994 Views)
Well, they are actually quite different even though the ACDCEstimator does use variance internally to it.

The StdDev function calculates a normal run of the mill statistical standard deviation on a dataset via the following information:

Computes the standard deviation and the mean (average) values of the input array using the following formulae:

Let: i = array index
n = number of elements

n-1
sDEV = Sqrt{Sum [x(i)-mean]**2/n]}
i=0

n-1
mean = Sum x(i)/n
i=0

Now, the ACDCEstimator function is quite different in that it applies a Hanning Window to your signal, makes a mean calculation and divides this result by half to find the DC estimate. The function th
en subtracts that DC estimate from the original signal, applies another Hanning Window to the resultant signal, calculates the variance of this, divides the variance result by 0.375, and takes the square root of the division to obtain the AC estimate.

The formula for the Hanning Window is as follows:

Hanning Window Details

If y represents the output sequence Hanning {X}, the VI obtains the elements of y using

y[i] = 0.5*x[i]*[1-cos(w)]

w = (2*PI*i)/n

for i = 0, 1, 2,�,n-1

where n is the number of elements in X.

So as you can see they are quite different processes altogether and you should use the StdDev for a statistical standard deviation calculation and the ACDCEstimator for a DC estimate as well as an AC rms estimate.

Jason F.
Applications Engineer
National Instruments
www.ni.com/ask
0 Kudos
Message 2 of 3
(3,995 Views)
I try to implement the algorithm you described
 
 CNiMath::ACDCEstimator(      m_WaveArray,       _ac_rms,       _dc);
 
For DC_Estimate
    //it applies a Hanning Window to your signal,
    // makes a mean calculation and divides this result by half to find the DC estimate.
    
    CNiReal64Vector WaveArray(m_WaveArray);
    CNiMath::WindowConstants wc;
    CNiMath::ScaledWindow(WaveArray, wc, static_cast<CNiMath::WindowType>(3));
    double DC_Estimate;
    CNiMath::Mean(WaveArray,DC_Estimate);
    ---> without divided by 2, DC_Estimate will be equal to _dc, is that your description wrong or something wrong in my implementation?
 
For AC estimate
    //The function then subtracts that DC estimate from the original signal,
    // applies another Hanning Window to the resultant signal,
    // calculates the variance of this, divides the variance result by 0.375,
    // and takes the square root of the division to obtain the AC estimate.
    for (i=0; i<m_WaveArray.GetSize(); i++)
   {
      WaveArray[i] = (m_WaveArray[i] - DC_Estimate);
   }
    CNiMath::ScaledWindow(WaveArray, wc, static_cast<CNiMath::WindowType>(3));
    double v_ac;
    CNiMath::Variance(WaveArray, v_ac);
    v_ac = sqrt(v_ac/0.375)/2; 
    ---> it needs to divide by2, then v_ac will be almost equal to _ac_rms, is that your description wrong or something wrong in my implementation?
0 Kudos
Message 3 of 3
(3,913 Views)