11 #ifndef __RobustEstimateZapper_h
12 #define __RobustEstimateZapper_h
16 #include "TextInterface.h"
37 void set_error_bar ( bool flag) { error = flag; }
40 bool get_log () const { return logarithmic; }
41 void set_log ( bool flag) { logarithmic = flag; }
45 void set_scale ( bool flag) { scale = flag; }
49 void set_cutoff_threshold ( float val) { threshold_max = threshold_min = val; }
53 void set_cutoff_threshold_min ( float val) { threshold_min = val; }
57 void set_cutoff_threshold_max ( float val) { threshold_max = val; }
69 val = sqrt(datum. var);
79 template< class Container, class Size, class Get, class Val id>
80 void excise ( unsigned iparam, Container* container, Size size, Get get, Valid valid)
82 unsigned npt = (container->*size)();
85 std::cerr << "RobustEstimateZapper::excise iparam=" << iparam << " npt=" << npt << std::endl;
88 std::vector<float> work (npt);
91 for ( unsigned ipt=0; ipt<npt; ipt++)
97 work[iwork] = get_value (val);
100 std::cout << iparam << " " << ipt << " " << work[iwork] << std::endl;
107 std::nth_element (work.begin(), work.begin()+iwork/2, work.begin()+iwork);
108 float median = work[ iwork/2 ];
115 for ( unsigned ipt=0; ipt < iwork; ipt++)
116 work[ipt] = fabs(work[ipt] - median);
119 std::nth_element (work.begin(), work.begin()+iwork/2, work.begin()+iwork);
120 madm = work[ iwork/2 ];
124 std::cerr << "RobustEstimateZapper::excise iwork=" << iwork
125 << " iparam=" << iparam << " median=" << median
126 << " madm=" << madm << std::endl;
129 unsigned excised = 0;
131 double max_extreme = median + threshold_max * madm;
132 double min_extreme = median - threshold_min * madm;
134 for ( unsigned ipt=0; ipt<npt; ipt++)
140 double test = get_value(val);
142 if (threshold_max && test > max_extreme)
145 std::cerr << "RobustEstimateZapper::excise zapping >max iparam=" << iparam
146 << " ipt=" << ipt << std::endl;
150 (container->*valid)(ipt, false);
153 if (threshold_min && test < min_extreme)
156 std::cerr << "RobustEstimateZapper::excise zapping <min iparam=" << iparam
157 << " ipt=" << ipt << std::endl;
161 (container->*valid)(ipt, false);
167 std::cerr << "RobustEstimateZapper::excise excised=" << excised << std::endl;
bool get_log() const Flag outliers based on the logarithm of either the value or the error bar. Definition: RobustEstimateZapper.h:45
float get_cutoff_threshold_max() const Set threshold used to identify outliers (multiple of madm) Definition: RobustEstimateZapper.h:61
float get_cutoff_threshold_min() const Set threshold used to identify outliers (multiple of madm) Definition: RobustEstimateZapper.h:57
An array of Value interfaces. Definition: TextInterfaceParser.h:35
T val The value, . Definition: Estimate.h:42
U var The variance of the value, . Definition: Estimate.h:44
bool get_scale() const Do not multiply threshold by MADM. Definition: RobustEstimateZapper.h:49
Manages Reference::To references to the instance. Definition: ReferenceAble.h:40
float get_cutoff_threshold() const Set threshold used to identify outliers (multiple of madm) Definition: RobustEstimateZapper.h:53
Excises outliers from a container using robust statistics. Definition: RobustEstimateZapper.h:22
bool get_error_bar() const Flag outliers based on their error bar. Definition: RobustEstimateZapper.h:41
TextInterface::Parser * get_interface() Return a text interface that can be used to access this instance. Definition: RobustEstimateZapper.C:38
Class text interface: an instance of C and a vector of Attribute<C> Definition: TextInterfaceTo.h:30
Generated using doxygen 1.8.17
|