template<typename type>
type FX::Maths::variance ( const type *FXRESTRICT  array,
FXuval  len,
FXuint  stride = 1,
const type *FXRESTRICT  _mean = 0 
) throw () [inline]

Computes the variance of an array.

Definition at line 1811 of file FXMaths.h.

References mean().

Referenced by stddev(), and variance().

01812     {
01813         type v=0, m=_mean ? *_mean : mean(array, len, stride);
01814         for(FXuval n=0; n<len; n+=stride)
01815         {
01816             const type d=array[n]-m;
01817             v+=d*d;
01818         }
01819         return v/((len/stride)-1);
01820     }


(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:38:01 2009 for TnFOX by doxygen v1.4.7