29 template <
class T,
class SzTp>
30 static T
getMax(T*,SzTp sz,SzTp& index_of_max);
35 template <
class T,
class SzTp>
39 { idxof = 0;
return sz > 0 ? 0 :
mUdf(T); }
41 for ( ; startidx<sz &&
mIsUdf(arr[startidx]); startidx++ )
43 if ( startidx+3 > sz )
44 { idxof = startidx;
return 0; }
46 T maxval = arr[startidx]; T minval = maxval, sum = maxval;
47 SzTp minidx = startidx, maxidx = startidx;
49 for ( SzTp idx=startidx+1; idx<sz; idx++ )
51 const T val = arr[idx];
52 if (
mIsUdf(val) )
continue;
54 if ( maxval < val ) { maxidx = idx; maxval = val; }
55 if ( minval > val ) { minidx = idx; minval = val; }
59 if ( maxval == minval || nonudfsz < 3 )
60 { idxof = startidx;
return 0; }
62 const T avg = sum / nonudfsz;
64 for ( SzTp idx=startidx; idx<sz; idx++ )
66 const T val = arr[idx];
67 if (
mIsUdf(val) )
continue;
69 const T delta = avg - arr[idx];
74 const T diffmin = avg - minval;
75 const T diffmax = maxval - avg;
76 idxof = diffmin > diffmax ? minidx : maxidx;
77 return (diffmin > diffmax ? diffmin : diffmax) / stdev;
#define mExpClass(module)
Definition: commondefs.h:160
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:287
Grubbs' test to detect outliers in a univariate data set assumed to come from a normally distributed ...
Definition: statgrubbs.h:25
static T getMax(T *, SzTp sz, SzTp &index_of_max)
Definition: statgrubbs.h:36
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:272
T getMax(const ArrayND< T > &in)
returns the Maximum of all defined values in the ArrrayND. Returns UDF if empty or only udfs encounte...
Definition: arrayndalgo.h:202
Statistics.
Definition: array2dinterpol.h:28