OpendTect-6_4  6.4
statruncalc.h
Go to the documentation of this file.
1 #ifndef statruncalc_h
2 #define statruncalc_h
3 /*+
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: Kristofer Tingdahl (org) / Bert Bril (rev)
8  Date: 10-12-1999 / Sep 2006
9  RCS: $Id$
10 ________________________________________________________________________
11 
12 -*/
13 
14 #include "algomod.h"
15 #include "convert.h"
16 #include "math2.h"
17 #include "simpnumer.h"
18 #include "sorting.h"
19 #include "stattype.h"
20 #include "typeset.h"
21 
22 #define mUndefReplacement 0
23 
26 namespace Stats
27 {
28 
39 {
40 public:
41  CalcSetup( bool weighted=false )
42  : weighted_(weighted)
43  , needextreme_(false)
44  , needsums_(false)
45  , needmed_(false)
46  , needvariance_(false)
47  , needmostfreq_(false) {}
48 
49  CalcSetup& require(Type);
50 
51  static int medianEvenHandling();
52 
53  bool isWeighted() const { return weighted_; }
54  bool needExtreme() const { return needextreme_; }
55  bool needSums() const { return needsums_; }
56  bool needMedian() const { return needmed_; }
57  bool needMostFreq() const { return needmostfreq_; }
58  bool needVariance() const { return needvariance_; }
59 
60 protected:
61 
62  template <class T>
63  friend class BaseCalc;
64  template <class T>
65  friend class RunCalc;
66  template <class T>
67  friend class WindowedCalc;
68  template <class T>
69  friend class ParallelCalc;
70 
71  bool weighted_;
73  bool needsums_;
74  bool needmed_;
77 
78 };
79 
80 
99 template <class T>
101 {
102 public:
103 
104  virtual ~BaseCalc() {}
105 
106  inline void clear();
107  const CalcSetup& setup() const { return setup_; }
108  bool isWeighted() const { return setup_.weighted_; }
109 
110  inline double getValue(Type) const;
111  inline int getIndex(Type) const;
112 
113  inline bool hasUndefs() const { return nrused_ != nradded_; }
114  inline int size( bool used=true ) const
115  { return used ? nrused_ : nradded_; }
116 
117  inline bool isEmpty() const { return size() == 0; }
118 
119  inline int count() const { return nrused_; }
120  inline double average() const;
121  inline T mostFreq() const;
122  inline T sum() const;
123  inline T min(int* index_of_min=0) const;
124  inline T max(int* index_of_max=0) const;
125  inline T extreme(int* index_of_extr=0) const;
126  inline T median(int* index_of_median=0) const;
127  inline T sqSum() const;
128  inline double rms() const;
129  inline double stdDev() const;
130  inline double normvariance() const;
131  virtual inline double variance() const;
132 
133  inline T clipVal(float ratio,bool upper) const;
135 
137 
138 protected:
139  BaseCalc( const CalcSetup& s )
140  : setup_(s) { clear(); }
141 
143 
144  int nradded_;
145  int nrused_;
146  int minidx_;
147  int maxidx_;
155 
159 
160  inline bool isZero( const T& t ) const;
161 };
162 
163 
164 template <> inline
165 bool BaseCalc<float>::isZero( const float& val ) const
166 { return mIsZero(val,1e-6); }
167 
168 
169 template <> inline
170 bool BaseCalc<double>::isZero( const double& val ) const
171 { return mIsZero(val,1e-10); }
172 
173 
174 template <class T> inline
175 bool BaseCalc<T>::isZero( const T& val ) const
176 { return !val; }
177 
178 
190 template <class T>
191 mClass(Algo) RunCalc : public BaseCalc<T>
192 {
193 public:
194  RunCalc( const CalcSetup& s )
195  : BaseCalc<T>(s) {}
196 
197  inline RunCalc<T>& addValue(T data,T weight=1);
198  inline RunCalc<T>& addValues(int sz,const T* data,const T* weights=0);
199  inline RunCalc<T>& replaceValue(T olddata,T newdata,T wt=1);
200  inline RunCalc<T>& removeValue(T data,T weight=1);
201 
202  inline RunCalc<T>& operator +=( T t ) { return addValue(t); }
203 
204  using BaseCalc<T>::medvals_;
205 
206 protected:
207 
208  inline void setMostFrequent(T val,T wt);
209 
210  using BaseCalc<T>::setup_;
211  using BaseCalc<T>::nradded_;
212  using BaseCalc<T>::nrused_;
213  using BaseCalc<T>::minidx_;
214  using BaseCalc<T>::maxidx_;
215  using BaseCalc<T>::maxval_;
216  using BaseCalc<T>::minval_;
217  using BaseCalc<T>::sum_x_;
218  using BaseCalc<T>::sum_xx_;
219  using BaseCalc<T>::sum_w_;
220  using BaseCalc<T>::sum_wx_;
221  using BaseCalc<T>::sum_wxx_;
222  using BaseCalc<T>::clss_;
223  using BaseCalc<T>::clsswt_;
224  using BaseCalc<T>::medwts_;
225 };
226 
227 
228 
236 template <class T>
238 {
239 public:
240  WindowedCalc( const CalcSetup& rcs, int sz )
241  : calc_(rcs)
242  , sz_(sz)
243  , wts_(calc_.isWeighted() ? new T [sz] : 0)
244  , vals_(new T [sz]) { clear(); }
246  { delete [] vals_; delete [] wts_; }
247  inline void clear();
248 
249  inline WindowedCalc& addValue(T data,T weight=1);
250  inline WindowedCalc& operator +=( T t ) { return addValue(t); }
251 
252  inline int getIndex(Type) const;
254  inline double getValue(Type) const;
255 
256  inline T count() const { return full_ ? sz_ : posidx_; }
257 
258 # define mRunCalc_DefEqFn(ret,fn) \
259  inline ret fn() const { return calc_.fn(); }
260  mRunCalc_DefEqFn(double, average)
262  mRunCalc_DefEqFn(double, normvariance)
265  mRunCalc_DefEqFn(double, rms)
266  mRunCalc_DefEqFn(double, stdDev)
267  mRunCalc_DefEqFn(T, mostFreq)
268 # undef mRunCalc_DefEqFn
269 
270  inline T min(int* i=0) const;
271  inline T max(int* i=0) const;
272  inline T extreme(int* i=0) const;
273  inline T median(int* i=0) const;
274 
275 protected:
276 
277  RunCalc<T> calc_; // has to be before wts_ (see constructor inits)
278  const int sz_;
279  T* wts_;
280  T* vals_;
281  int posidx_;
282  bool empty_;
283  bool full_;
284  bool needcalc_;
285 
286  inline void fillCalc(RunCalc<T>&) const;
287 };
288 
289 
290 
291 template <class T> inline
293 {
294  sum_x_ = sum_w_ = sum_xx_ = sum_wx_ = sum_wxx_ = 0;
295  nradded_ = nrused_ = minidx_ = maxidx_ = 0;
296  minval_ = maxval_ = mUdf(T);
297  clss_.erase(); clsswt_.erase(); medvals_.erase(); medwts_.erase();
298 }
299 
300 
301 template <class T> inline
303 {
304  switch ( t )
305  {
306  case Count: return count();
307  case Average: return average();
308  case Median: return median();
309  case RMS: return rms();
310  case StdDev: return stdDev();
311  case Variance: return variance();
312  case NormVariance: return normvariance();
313  case Min: return min();
314  case Max: return max();
315  case Extreme: return extreme();
316  case Sum: return sum();
317  case SqSum: return sqSum();
318  case MostFreq: return mostFreq();
319  }
320 
321  return 0;
322 }
323 
324 
325 template <class T> inline
327 {
328  int ret;
329  switch ( t )
330  {
331  case Min: (void)min( &ret ); break;
332  case Max: (void)max( &ret ); break;
333  case Extreme: (void)extreme( &ret ); break;
334  case Median: (void)median( &ret ); break;
335  default: ret = 0; break;
336  }
337  return ret;
338 }
339 
340 
341 
342 #undef mBaseCalc_ChkEmpty
343 #define mBaseCalc_ChkEmpty(typ) \
344  if ( nrused_ < 1 ) return mUdf(typ);
345 
346 template <class T>
347 inline double BaseCalc<T>::stdDev() const
348 {
349  mBaseCalc_ChkEmpty(double);
350 
351  double v = variance();
352  return v > 0 ? Math::Sqrt( v ) : 0;
353 }
354 
355 
356 template <class T>
357 inline double BaseCalc<T>::average() const
358 {
359  mBaseCalc_ChkEmpty(double);
360 
361  if ( !setup_.weighted_ )
362  return ((double)sum_x_) / nrused_;
363 
364  return this->isZero(sum_w_) ? mUdf(double) : ((double)sum_wx_) / sum_w_;
365 }
366 
367 
368 template <class T>
369 inline T BaseCalc<T>::sum() const
370 {
372  return sum_x_;
373 }
374 
375 
376 template <class T>
377 inline T BaseCalc<T>::sqSum() const
378 {
380  return sum_xx_;
381 }
382 
383 
384 template <class T>
385 inline double BaseCalc<T>::rms() const
386 {
387  mBaseCalc_ChkEmpty(double);
388 
389  if ( !setup_.weighted_ )
390  return Math::Sqrt( ((double)sum_xx_) / nrused_ );
391 
392  return this->isZero(sum_w_) ? mUdf(double)
393  : Math::Sqrt( ((double)sum_wxx_)/sum_w_ );
394 }
395 
396 
397 template <class T>
398 inline double BaseCalc<T>::variance() const
399 {
400  if ( nrused_ < 2 ) return 0;
401 
402  if ( !setup_.weighted_ )
403  return ( sum_xx_ - (sum_x_ * ((double)sum_x_) / nrused_) )
404  / (nrused_ - 1);
405 
406  return (sum_wxx_ - (sum_wx_ * ((double)sum_wx_) / sum_w_) )
407  / ( (nrused_-1) * ((double)sum_w_) / nrused_ );
408 }
409 
410 
411 template <>
413 {
414  pErrMsg("Undefined operation for float_complex in template");
415  return mUdf(double);
416 }
417 
418 
419 template <class T>
420 inline double BaseCalc<T>::normvariance() const
421 {
422  if ( nrused_ < 2 ) return 0;
423 
424  double fact = 0.1;
425  double avg = average();
426  double var = variance();
427  const double divisor = avg*avg + fact*var;
428  if ( mIsZero(divisor,mDefEps) )
429  return 0;
430 
431  return var / divisor;
432 }
433 
434 
435 template <class T>
436 inline T BaseCalc<T>::min( int* index_of_min ) const
437 {
438  if ( index_of_min ) *index_of_min = minidx_;
440  return minval_;
441 }
442 
443 
444 template <class T>
445 inline T BaseCalc<T>::max( int* index_of_max ) const
446 {
447  if ( index_of_max ) *index_of_max = maxidx_;
449  return maxval_;
450 }
451 
452 
453 template <class T>
454 inline T BaseCalc<T>::extreme( int* index_of_extr ) const
455 {
456  if ( index_of_extr ) *index_of_extr = 0;
458 
459  const T maxcmp = maxval_ < 0 ? -maxval_ : maxval_;
460  const T mincmp = minval_ < 0 ? -minval_ : minval_;
461  if ( maxcmp < mincmp )
462  {
463  if ( index_of_extr ) *index_of_extr = minidx_;
464  return minval_;
465  }
466  else
467  {
468  if ( index_of_extr ) *index_of_extr = maxidx_;
469  return maxval_;
470  }
471 }
472 
473 
474 template <class T>
475 inline T BaseCalc<T>::clipVal( float ratio, bool upper ) const
476 {
478  (void)median();
479  const int lastidx = medvals_.size();
480  const float fidx = ratio * lastidx;
481  const int idx = fidx <= 0 ? 0 : (fidx > lastidx ? lastidx : (int)fidx);
482  return medvals_[upper ? lastidx - idx : idx];
483 }
484 
485 
486 template <class T>
487 inline T BaseCalc<T>::mostFreq() const
488 {
489  if ( clss_.isEmpty() )
490  return mUdf(T);
491 
492  T maxwt = clsswt_[0]; int ret = clss_[0];
493  for ( int idx=1; idx<clss_.size(); idx++ )
494  {
495  if ( clsswt_[idx] > maxwt )
496  { maxwt = clsswt_[idx]; ret = clss_[idx]; }
497  }
498 
499  return (T)ret;
500 }
501 
502 
503 template<> inline
505 { return mUdf(float_complex); }
506 
507 
508 template <class T> inline
509 T computeMedian( const T* data, int sz, int pol, int* idx_of_med )
510 {
511  if ( idx_of_med ) *idx_of_med = 0;
512  if ( sz < 2 )
513  return sz < 1 ? mUdf(T) : data[0];
514 
515  int mididx = sz / 2;
516  T* valarr = const_cast<T*>( data );
517  if ( !idx_of_med )
518  {
519  if ( sz<=255 || !is8BitesData(valarr,sz,100) ||
520  !duplicate_sort(valarr,sz,256) )
521  {
522  quickSort( valarr, sz );
523  }
524  }
525  else
526  {
527  mGetIdxArr( int, idxs, sz );
528  quickSort( valarr, idxs, sz );
529  *idx_of_med = idxs[ mididx ];
530  delete [] idxs;
531  }
532 
533  if ( sz%2 == 0 )
534  {
535  if ( pol == 0 )
536  return (data[mididx] + data[mididx-1]) / 2;
537  else if ( pol == 1 )
538  mididx--;
539  }
540 
541  return data[ mididx ];
542 }
543 
544 
545 template <class T> inline
546 T computeWeightedMedian( const T* data, const T* wts, int sz,
547  int* idx_of_med )
548 {
549  if ( idx_of_med ) *idx_of_med = 0;
550  if ( sz < 2 )
551  return sz < 1 ? mUdf(T) : data[0];
552 
553  T* valarr = const_cast<T*>( data );
554  mGetIdxArr( int, idxs, sz );
555  quickSort( valarr, idxs, sz );
556  T* wtcopy = new T[sz];
557  OD::memCopy( wtcopy, wts, sz*sizeof(T) );
558  float wsum = 0;
559  for ( int idx=0; idx<sz; idx++ )
560  {
561  const_cast<T&>(wts[idx]) = wtcopy[ idxs[idx] ];
562  wsum += (float) wts[idx];
563  }
564  delete [] idxs;
565 
566  const float hwsum = wsum * 0.5f;
567  wsum = 0;
568  int medidx = 0;
569  for ( int idx=0; idx<sz; idx++ )
570  {
571  wsum += (float) wts[idx];
572  if ( wsum >= hwsum )
573  { medidx = idx; break; }
574  }
575  if ( idx_of_med ) *idx_of_med = medidx;
576  return valarr[ medidx ];
577 }
578 
579 
580 template <class T>
581 inline T BaseCalc<T>::median( int* idx_of_med ) const
582 {
583  const int policy = setup_.medianEvenHandling();
584  const int sz = medvals_.size();
585  const T* vals = medvals_.arr();
586  return setup_.weighted_ ?
587  computeWeightedMedian( vals, medwts_.arr(), sz, idx_of_med )
588  : computeMedian( vals, sz, policy, idx_of_med );
589 }
590 
591 
592 
593 
594 template <class T> inline
596 {
597  nradded_++;
598  if ( mIsUdf(val) )
599  return *this;
600  if ( setup_.weighted_ && (mIsUdf(wt) || this->isZero(wt)) )
601  return *this;
602 
603  if ( setup_.needmed_ )
604  {
605  medvals_ += val;
606  if ( setup_.weighted_ )
607  medwts_ += wt;
608  }
609 
610  if ( setup_.needextreme_ )
611  {
612  if ( nrused_ == 0 )
613  minval_ = maxval_ = val;
614  else
615  {
616  if ( val < minval_ ) { minval_ = val; minidx_ = nradded_ - 1; }
617  if ( val > maxval_ ) { maxval_ = val; maxidx_ = nradded_ - 1; }
618  }
619  }
620 
621  if ( setup_.needmostfreq_ )
622  setMostFrequent( val, wt );
623 
624  if ( setup_.needsums_ )
625  {
626  sum_x_ += val;
627  sum_xx_ += val * val;
628  if ( setup_.weighted_ )
629  {
630  sum_w_ += wt;
631  sum_wx_ += wt * val;
632  sum_wxx_ += wt * val * val;
633  }
634  }
635 
636  nrused_++;
637  return *this;
638 }
639 
640 
641 template <class T> inline
642 void RunCalc<T>::setMostFrequent( T val, T wt )
643 {
644  int ival; Conv::set( ival, val );
645  int setidx = clss_.indexOf( ival );
646 
647  if ( setidx < 0 )
648  { clss_ += ival; clsswt_ += wt; }
649  else
650  clsswt_[setidx] += wt;
651 }
652 
653 
654 template <> inline
656  float_complex wt )
657 { pErrMsg("Undefined operation for float_complex in template"); }
658 
659 
660 template <class T> inline
662 {
663  nradded_--;
664  if ( mIsUdf(val) )
665  return *this;
666  if ( setup_.weighted_ && (mIsUdf(wt) || this->isZero(wt)) )
667  return *this;
668 
669  if ( setup_.needmed_ )
670  {
671  int idx = medvals_.size();
672  while ( true )
673  {
674  idx = medvals_.indexOf( val, false, idx-1 );
675  if ( idx < 0 ) break;
676  if ( setup_.weighted_ && medwts_[idx] == wt )
677  {
678  medvals_.removeSingle( idx );
679  medwts_.removeSingle( idx );
680  break;
681  }
682  }
683  }
684 
685  if ( setup_.needmostfreq_ )
686  {
687  int ival; Conv::set( ival, val );
688  int setidx = clss_.indexOf( ival );
689  int iwt = 1;
690  if ( setup_.weighted_ )
691  Conv::set( iwt, wt );
692 
693  if ( setidx >= 0 )
694  {
695  clsswt_[setidx] -= wt;
696  if ( clsswt_[setidx] <= 0 )
697  {
698  clss_.removeSingle( setidx );
699  clsswt_.removeSingle( setidx );
700  }
701  }
702  }
703 
704  if ( setup_.needsums_ )
705  {
706  sum_x_ -= val;
707  sum_xx_ -= val * val;
708  if ( setup_.weighted_ )
709  {
710  sum_w_ -= wt;
711  sum_wx_ -= wt * val;
712  sum_wxx_ -= wt * val * val;
713  }
714  }
715 
716  nrused_--;
717  return *this;
718 }
719 
720 
721 template <class T> inline
722 RunCalc<T>& RunCalc<T>::addValues( int sz, const T* data, const T* weights )
723 {
724  for ( int idx=0; idx<sz; idx++ )
725  addValue( data[idx], weights ? weights[idx] : 1 );
726  return *this;
727 }
728 
729 
730 template <class T> inline
731 RunCalc<T>& RunCalc<T>::replaceValue( T oldval, T newval, T wt )
732 {
733  removeValue( oldval, wt );
734  return addValue( newval, wt );
735 }
736 
737 
738 
739 
740 template <class T> inline
742 {
743  posidx_ = 0; empty_ = true; full_ = false;
744  needcalc_ = calc_.setup().needSums() || calc_.setup().needMostFreq();
745  calc_.clear();
746 }
747 
748 
749 template <class T> inline
751 {
752  if ( empty_ ) return;
753 
754  const int stopidx = full_ ? sz_ : posidx_;
755  for ( int idx=posidx_; idx<stopidx; idx++ )
756  calc.addValue( vals_[idx], wts_ ? wts_[idx] : 1 );
757  for ( int idx=0; idx<posidx_; idx++ )
758  calc.addValue( vals_[idx], wts_ ? wts_[idx] : 1 );
759 }
760 
761 
762 template <class T> inline
764 {
765  switch ( t )
766  {
767  case Min: return min();
768  case Max: return max();
769  case Extreme: return extreme();
770  case Median: return median();
771  default: break;
772  }
773  return calc_.getValue( t );
774 }
775 
776 
777 template <class T> inline
779 {
780  int ret;
781  switch ( t )
782  {
783  case Min: (void)min( &ret ); break;
784  case Max: (void)max( &ret ); break;
785  case Extreme: (void)extreme( &ret ); break;
786  case Median: (void)median( &ret ); break;
787  default: ret = 0; break;
788  }
789  return ret;
790 }
791 
792 
793 template <class T> inline
794 T WindowedCalc<T>::min( int* index_of_min ) const
795 {
796  RunCalc<T> calc( CalcSetup().require(Stats::Min) );
797  fillCalc( calc );
798  return calc.min( index_of_min );
799 }
800 
801 
802 template <class T> inline
803 T WindowedCalc<T>::max( int* index_of_max ) const
804 {
805  RunCalc<T> calc( CalcSetup().require(Stats::Max) );
806  fillCalc( calc );
807  return calc.max( index_of_max );
808 }
809 
810 
811 template <class T> inline
812 T WindowedCalc<T>::extreme( int* index_of_extr ) const
813 {
814  RunCalc<T> calc( CalcSetup().require(Stats::Extreme) );
815  fillCalc( calc );
816  return calc.extreme( index_of_extr );
817 }
818 
819 
820 template <class T> inline
821 T WindowedCalc<T>::median( int* index_of_med ) const
822 {
823  CalcSetup rcs( calc_.setup().weighted_ );
824  RunCalc<T> calc( rcs.require(Stats::Median) );
825  fillCalc( calc );
826  return calc.median( index_of_med );
827 }
828 
829 
830 template <class T>
832 {
833  if ( needcalc_ )
834  {
835  if ( !full_ )
836  calc_.addValue( val, wt );
837  else
838  {
839  if ( !wts_ || wt == wts_[posidx_] )
840  calc_.replaceValue( vals_[posidx_], val, wt );
841  else
842  {
843  calc_.removeValue( vals_[posidx_], wts_[posidx_] );
844  calc_.addValue( val, wt );
845  }
846  }
847  }
848 
849  vals_[posidx_] = val;
850  if ( wts_ ) wts_[posidx_] = wt;
851 
852  posidx_++;
853  if ( posidx_ >= sz_ )
854  { full_ = true; posidx_ = 0; }
855 
856  empty_ = false;
857  return *this;
858 }
859 
860 #undef mRunCalc_ChkEmpty
861 
862 }; // namespace Stats
863 
864 #endif
bool needextreme_
Definition: statruncalc.h:72
Definition: stattype.h:27
#define mExpClass(module)
Definition: commondefs.h:160
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:287
T maxval_
Definition: statruncalc.h:149
#define mGetIdxArr(tp, var, sz)
Creates new array of an integer type filled with index.
Definition: commondefs.h:253
BaseCalc(const CalcSetup &s)
Definition: statruncalc.h:139
T median(int *i=0) const
Definition: statruncalc.h:821
bool needMedian() const
Definition: statruncalc.h:56
T count() const
Definition: statruncalc.h:256
#define mBaseCalc_ChkEmpty(typ)
Definition: statruncalc.h:343
bool is8BitesData(const T *vals, od_int64 sz, const unsigned int samplesz=100)
Definition: simpnumer.h:420
int maxidx_
Definition: statruncalc.h:147
Setup for the Stats::RunCalc and Stats::ParallelCalc objects.
Definition: statruncalc.h:38
const CalcSetup & setup() const
Definition: statruncalc.h:107
Definition: stattype.h:27
int getIndex(Type) const
only for Median, Min and Max
Definition: statruncalc.h:326
bool needvariance_
Definition: statruncalc.h:76
T minval_
Definition: statruncalc.h:148
Definition: stattype.h:25
T sum() const
Definition: statruncalc.h:369
#define mIsZero(x, eps)
Definition: commondefs.h:53
double normvariance() const
Definition: statruncalc.h:420
RunCalc< T > & replaceValue(T olddata, T newdata, T wt=1)
Definition: statruncalc.h:731
void clear()
Definition: statruncalc.h:292
T * vals_
Definition: statruncalc.h:280
double getValue(Type) const
Definition: statruncalc.h:763
RunCalc< T > & removeValue(T data, T weight=1)
Definition: statruncalc.h:661
RunCalc< T > & addValues(int sz, const T *data, const T *weights=0)
Definition: statruncalc.h:722
void clear(std::ios &)
int minidx_
Definition: statruncalc.h:146
bool isWeighted() const
Definition: statruncalc.h:53
RunCalc(const CalcSetup &s)
Definition: statruncalc.h:194
void clear()
Definition: statruncalc.h:741
int posidx_
Definition: statruncalc.h:281
void set(T &_to, const F &fr)
template based type conversion
Definition: convert.h:29
double getValue(Type) const
Definition: statruncalc.h:302
T computeWeightedMedian(const T *data, const T *wts, int sz, int *idx_of_med)
Definition: statruncalc.h:546
TypeSet< int > clss_
Definition: statruncalc.h:156
T max(int *index_of_max=0) const
Definition: statruncalc.h:445
RunCalc< T > & addValue(T data, T weight=1)
Definition: statruncalc.h:595
Definition: stattype.h:26
Stats computation running in parallel.
Definition: statparallelcalc.h:33
T median(int *index_of_median=0) const
Definition: statruncalc.h:581
bool needVariance() const
Definition: statruncalc.h:58
int nrused_
Definition: statruncalc.h:145
float variance(const X &x, int sz)
Definition: simpnumer.h:288
virtual double variance() const
Definition: statruncalc.h:398
Type
Definition: stattype.h:21
bool needExtreme() const
Definition: statruncalc.h:54
void quickSort(T *arr, I sz)
Definition: sorting.h:259
bool needSums() const
Definition: statruncalc.h:55
int getIndex(Type) const
Only use for Min, Max or Median.
Definition: statruncalc.h:778
bool duplicate_sort(T *arr, I sz, int maxnrvals)
Definition: sorting.h:72
int count() const
Definition: statruncalc.h:119
bool needcalc_
Definition: statruncalc.h:284
TypeSet< T > clsswt_
Definition: statruncalc.h:157
void setMostFrequent(T val, T wt)
Definition: statruncalc.h:642
bool needmed_
Definition: statruncalc.h:74
bool isEmpty() const
Definition: statruncalc.h:117
Set of (small) copyable elements.
Definition: commontypes.h:30
Definition: stattype.h:26
bool needMostFreq() const
Definition: statruncalc.h:57
T sum_xx_
Definition: statruncalc.h:151
int nradded_
Definition: statruncalc.h:144
T computeMedian(const T *data, int sz, int pol, int *idx_of_med)
Definition: statruncalc.h:509
T * wts_
Definition: statruncalc.h:279
int size(bool used=true) const
Definition: statruncalc.h:114
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:272
T mostFreq() const
Definition: statruncalc.h:487
WindowedCalc(const CalcSetup &rcs, int sz)
Definition: statruncalc.h:240
T min(int *i=0) const
Definition: statruncalc.h:794
Definition: stattype.h:24
Definition: stattype.h:28
std::complex< float > float_complex
Definition: odcomplex.h:18
TypeSet< T > medvals_
Definition: statruncalc.h:136
RunCalc manager which buffers a part of the data.
Definition: statruncalc.h:237
T extreme(int *i=0) const
Definition: statruncalc.h:812
Definition: stattype.h:24
bool empty_
Definition: statruncalc.h:282
T extreme(int *index_of_extr=0) const
Definition: statruncalc.h:454
#define mDefEps
Definition: commondefs.h:58
Definition: stattype.h:25
~WindowedCalc()
Definition: statruncalc.h:245
double rms() const
Definition: statruncalc.h:385
bool weighted_
Definition: statruncalc.h:71
double stdDev() const
Definition: statruncalc.h:347
bool hasUndefs() const
Definition: statruncalc.h:113
CalcSetup(bool weighted=false)
Definition: statruncalc.h:41
Calculates mean, min, max etc., as running values.
Definition: statruncalc.h:191
void fillCalc(RunCalc< T > &) const
Definition: statruncalc.h:750
T clipVal(float ratio, bool upper) const
require median; 0 <= ratio <= 1
Definition: statruncalc.h:475
T sum_wx_
Definition: statruncalc.h:153
Definition: stattype.h:25
Base class to calculate mean, min, max, etc.. can be used either as running values (Stats::RunCalc) o...
Definition: statruncalc.h:100
virtual ~BaseCalc()
Definition: statruncalc.h:104
bool full_
Definition: statruncalc.h:283
Statistics.
Definition: array2dinterpol.h:28
T min(int *index_of_min=0) const
Definition: statruncalc.h:436
#define mRunCalc_DefEqFn(ret, fn)
Definition: statruncalc.h:258
Definition: stattype.h:23
const int sz_
Definition: statruncalc.h:278
T sum_x_
Definition: statruncalc.h:150
T sum_wxx_
Definition: statruncalc.h:154
T sum_w_
Definition: statruncalc.h:152
RunCalc< T > calc_
Definition: statruncalc.h:277
T sqSum() const
Definition: statruncalc.h:377
Definition: stattype.h:24
bool needsums_
Definition: statruncalc.h:73
CalcSetup setup_
Definition: statruncalc.h:142
double average() const
Definition: statruncalc.h:357
#define mClass(module)
Definition: commondefs.h:164
Definition: stattype.h:26
#define pErrMsg(msg)
Definition: errmsg.h:60
bool isZero(const T &t) const
Definition: statruncalc.h:175
T max(int *i=0) const
Definition: statruncalc.h:803
bool isWeighted() const
Definition: statruncalc.h:108
bool needmostfreq_
Definition: statruncalc.h:75
float Sqrt(float)
TypeSet< T > medwts_
Definition: statruncalc.h:158
WindowedCalc & addValue(T data, T weight=1)
Definition: statruncalc.h:831

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019