Statistics in a Channel

Recommended Posts


I'd like to get the Standard Deviation and Mean of all the data in the channel.

Say I have a channel with 7 columns and hundreds (if not thousands) of rows. I tried to use Stddev(), but it only returns a series of standard deviations, one for each column. I have no use for this. 

Is there a DAQ function to calculate the Standard deviation that calculates the standard deviation based off ALL the data in all the rows and columns? 


Any guidance or advice would be glorious. 


Link to comment
Share on other sites

The stat functions have multiple forms.  The regular version, stdDev() does a standard deviation across rows, meaning if you have an array with 10 columns and 100 rows, you'll end up with a result with 1 row and 10 columns containing the stdDev of each column of the original.  There is also a cols and depth version of these controls.  So, stdDevCols() of my original 100x10 array would instead do a stddev across each row resulting in an array with 100 rows and 1 column.  Note that History in a channel or variable is always added in the rows dimension.

There is no built in function to do statistics on an entire array as a whole resulting in a single scalar value.  However, there is the more generic function, flatten() available in 18.1 that will take any array of any dimensions and make it into one with just rows.  So a 100x10 array becomes a 1000x1 array, and a 5 x 4 x 3 array becomes a 60x1x1 array.  Then you can use the regular stdDev on it:



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.