cwVectOps.h : Added std().
This commit is contained in:
parent
8c37bbe0f0
commit
570e4cfc45
17
cwVectOps.h
17
cwVectOps.h
@ -342,6 +342,23 @@ namespace cw
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user