8 if(sample>median) ++runningDiff;
9 if(sample<median) --runningDiff;
11 if(runningDiff > ncontig){
15 if(runningDiff < -1*ncontig){
22 const int lookahead,
const int threshold,
26 std::vector<short> ped(raw_in.size(), 0);
30 for(
size_t i=0; i<raw_in.size()-lookahead; ++i){
32 short sig_cand=raw_in[i+lookahead];
34 bool cand_above=(sig_cand>median+threshold);
36 bool current_below=(s<median+threshold);
38 if(updating && cand_above){
42 if( (!updating) && (current_below)){
53 for(
size_t i=raw_in.size()-lookahead; i<raw_in.size(); ++i){
59 std::vector<short>
frugal_iqr(
const std::vector<short>& raw_in,
60 const std::vector<short>&
median,
63 std::vector<short> iqr(raw_in.size(), 0);
68 short quartileLo=median[0]-1;
69 short quartileHi=median[0]+1;
71 for(
size_t i=0; i<raw_in.size(); ++i){
80 iqr[i]=quartileHi-quartileLo;
90 std::vector<short> ped(raw_in.size(), 0);
93 for(
size_t i=0; i<raw_in.size(); ++i){
105 const size_t ntaps,
const short* taps)
107 std::vector<short> filtered(input.size(), 0);
108 for(
size_t i=0; i<input.size(); ++i){
109 for(
size_t j=0; j<ntaps; ++j){
110 const size_t index=i>j ? i-j : 0;
111 filtered[i]+=input[
index]*taps[j];
void do_frugal_update(short &median, int &runningDiff, const short sample, const int ncontig)
std::vector< short > apply_fir_filter(const std::vector< short > &input, const size_t ntaps, const short *taps)
std::vector< short > frugal_iqr(const std::vector< short > &raw_in, const std::vector< short > &median, const int ncontig)
std::vector< short > frugal_pedestal_sigkill(const std::vector< short > &raw_in, const int lookahead, const int threshold, const int ncontig)
std::vector< short > frugal_pedestal(const std::vector< short > &raw_in, const int ncontig)
double median(sqlite3 *db, std::string const &table_name, std::string const &column_name)