enhering

statistics

Sep 8th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. void Data::UpdateStatistics() {
  2. uint8_t nCount;
  3. DataType Sum = 0;
  4. DataType SumSqr = 0;
  5. DataType Value = 0;
  6.  
  7. for (nCount = 0; nCount < VECTOR_POSITIONS; nCount++) {
  8.  
  9. Value = m_DatapointArray[nCount];
  10. Sum += Value;
  11. SumSqr += Value * Value;
  12. }
  13.  
  14. m_StdDev = sqrt( (m_nNumSamples * SumSqr) - (Sum * Sum) ) / m_nNumSamples;
  15. m_Average = Sum / m_nNumSamples;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment