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

Computes the mean, max, min and mode of an array.

Definition at line 1790 of file FXMaths.h.

References max(), and min().

Referenced by distribution(), mean(), and variance().

01791     {
01792         type m=0;
01793         if(min) *min=Generic::BiggestValue<type>::value;
01794         if(max) *max=Generic::BiggestValue<type, true>::value;
01795         if(mode) *mode=0;
01796         for(FXuval n=0; n<len; n+=stride)
01797         {
01798             m+=array[n];
01799             if(min && array[n]<*min) *min=array[n];
01800             if(max && array[n]>*max) *max=array[n];
01801             if(mode && (len/2==n || (len+1)/2==n)) *mode=*mode ? (*mode+array[n])/2 : array[n];
01802         }
01803         return m/len;
01804     }


(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