cwVectOps.h : Added std().

This commit is contained in:
kevin 2023-09-12 17:42:30 -04:00
parent 8c37bbe0f0
commit 570e4cfc45

View File

@ -343,6 +343,23 @@ namespace cw
return sum(v,n)/n; return sum(v,n)/n;
} }
template< typename T >
double std( const T* v, unsigned n )
{
if( n < 2 )
return 0;
double u = mean(v,n);
double dsum = 0;
for(unsigned i=0; i<n; ++i)
{
double d = v[i] - u;
dsum += d*d;
}
return sqrt(dsum/n);
}
//================================================================================================================== //==================================================================================================================
// Signal Processing // Signal Processing
// //