Changeset 3241


Ignore:
Timestamp:
May 24, 2014, 4:34:06 PM (7 years ago)
Author:
Peter
Message:

prefer range constructor over assigning with std::copy. remove dead code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/statistics/TukeyBiweightEstimator.h

    r2817 r3241  
    109109    // if not sorted, create a sorted copy
    110110    typedef typename std::iterator_traits<RandomAccessIterator> traits;
    111     std::vector<typename traits::value_type> vec;
    112     vec.reserve(last-first);
    113     std::copy(first, last, std::back_inserter(vec));
     111    std::vector<typename traits::value_type> vec(first, last);
    114112    std::sort(vec.begin(), vec.end());
    115113    return estimate(vec.begin(), vec.end());
    116 
    117     const double scale = mad(first, last, true);
    118     double m = median(first, last, true);
    119     if (scale==0)
    120       return m;
    121     // ensure m != m0
    122     double m0 = m+1.0;
    123     size_t epoch = 0;
    124     while (m!=m0) {
    125       m0 = m;
    126       m = estimate(first, last, m, scale);
    127       ++epoch;
    128       if (epoch>1000)
    129         utility::runtime_error("TukeyBiweightIterator: too many epochs");
    130     }
    131     return m;
    132114  }
    133115
Note: See TracChangeset for help on using the changeset viewer.