template<unsigned int buckets, typename type>
Vector<type, buckets+3> FX::Maths::distribution ( const type *FXRESTRICT  array,
FXuval  len,
FXuint  stride = 1,
const type *FXRESTRICT  min = 0,
const type *FXRESTRICT  max = 0 
) throw () [inline]

Computes distribution of an array. Returns min, max & bucket size in first three items.

Definition at line 1837 of file FXMaths.h.

References max(), mean(), and min().

01838     {
01839         Vector<type, buckets+3> ret;
01840         const type &_min=(min && max) ? *min : ret[0], &_max=(min && max) ? *max : ret[1];
01841         type &div=ret[2];
01842         if(!min || !max)
01843             mean(array, len, stride, &ret[0], &ret[1]);
01844         div=(_max-_min)/buckets;
01845         for(FXuval n=0; n<len; n+=stride)
01846         {
01847             for(FXuval bucket=0; bucket<buckets; bucket++)
01848             {
01849                 if(array[n]>=_min+div*bucket && array[n]<_min+div*(bucket+1))
01850                     ++ret[3+bucket];
01851             }
01852         }
01853         return ret;
01854     }


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