DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Kurtosis and Skewness

Is there a way to calculate Kurtosis and Skewness value for each each second of data that is a long set of 360secs? Basically speaking, I need 360 values of kurtosis and skewness.

0 Kudos
Message 1 of 3
(2,548 Views)
Set Group = Data.Root.ChannelGroups(1)
Set DatChannel = Group.Channels(1)
Set KurtosisChannel = Group.Channels.Add("Kurtosis", DataTypeChnFloat64)
Set SkewnessChannel = Group.Channels.Add("Skewness", DataTypeChnFloat64)
FOR n = 1 TO 23
  StatSel(n) = "No"
NEXT ' n
StatSel(22)  = "Yes" ' Kurtosis
StatSel(21)  = "Yes" ' Skewness
StatResChn = FALSE
StatClipCopy = FALSE
StatClipValue = FALSE
iMax  = DatChannel.Size
Start = DatChannel.Properties("wf_start_offset").Value
Delta = DatChannel.Properties("wf_increment").Value
Call ChnWfPropSet(KurtosisChannel, "Time", "s", (Start+1)/2, 1)
Call ChnWfPropSet(SkewnessChannel, "Time", "s", (Start+1)/2, 1)
SecVals = 1/Delta
FOR i = 1 TO iMax Step SecVals
  k = k + 1
  P1 = i
  P2 = CStr(i+SecVals-1)
  IF P2 > iMax THEN P2 = iMax
  RowRange = P1 & "-" & P2
  Call StatBlockCalc("Channel", RowRange, DatChannel)
  KurtosisChannel(k) = StatKurtosis
  SkewnessChannel(k) = StatSkew
NEXT ' Until end of channel

I am using the above script to find values. I am getting all the values I need. Here is the thing, the skewness values are negative and kurtosis are positive.

 

But when I run statistical values on the whole data, my skewnedd value is positive and kurtosis is negative.

 

Is that correct or is something wrong in my script?

0 Kudos
Message 2 of 3
(2,541 Views)

Hey hmurya,

 

Thanks for posting. On first glance that would be how I would expect to calculate the kurtosis and skewness according to our documentation.

 

Command: StatBlockCalc - http://zone.ni.com/reference/en-XX/help/370859J-01/comoff/statblockcalc/

 

Maybe it might be good to try a clean known data set and see if we still see the same results. I think our Kurtosis should be 3 if we're testing a normal distribution and it should be 1 if we're testing a discrete distribution (discrete: equally likely values). From there we could also do a quick check on the skewness since it has a relation to the Kurtosis.

 

Hopefully that gives us a good starting place to figure out our script is doing what we want.

JY
Application Engineer, RF and Communications
National Instruments
0 Kudos
Message 3 of 3
(2,499 Views)