Changeset 1738 for trunk/yat/normalizer/qQuantileNormalizer.cc
 Timestamp:
 Jan 20, 2009, 2:58:44 AM (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/normalizer/qQuantileNormalizer.cc
r1736 r1738 24 24 #include "yat/regression/CSplineInterpolation.h" 25 25 #include "yat/statistics/Averager.h" 26 #include "yat/statistics/AveragerWeighted.h" 27 #include "yat/utility/DataWeight.h" 26 28 #include "yat/utility/Vector.h" 27 29 #include "yat/utility/VectorBase.h" 30 #include "yat/utility/WeightIterator.h" 28 31 29 32 #include <algorithm> 30 33 #include <cassert> 34 #include <numeric> 35 #include <sstream> 36 #include <stdexcept> 37 #include <string> 38 #include <vector> 31 39 32 40 namespace theplu { … … 57 65 58 66 67 void qQuantileNormalizer::Partitioner::init 68 (const std::vector<utility::DataWeight>& sortedvec, unsigned int N) 69 { 70 assert(N>1); 71 assert(N<=sortedvec.size()); 72 double total_w = std::accumulate(utility::weight_iterator(sortedvec.begin()), 73 utility::weight_iterator(sortedvec.end()), 74 0.0); 75 76 assert(total_w); 77 double sum_w = 0; 78 std::vector<utility::DataWeight>::const_iterator iter(sortedvec.begin()); 79 for (unsigned int i=0; i<N; ++i) { 80 statistics::AveragerWeighted av; 81 double end_sum_w = (i+1) * total_w / N  sum_w; 82 std::cout << "end_sum_w: " << end_sum_w << std::endl; 83 if (i!=N1) { 84 while(av.sum_w() < end_sum_w) { 85 av.add(iter>data(), iter>weight()); 86 ++iter; 87 } 88 } 89 // use all remaining data for last bin (to avoid problems 90 // due to rounding errors) 91 else 92 add(av, iter, sortedvec.end()); 93 94 if (av.sum_w() == 0) { 95 std::stringstream ss; 96 ss << "yat::normalizer::qQuantileNormalizer: relative weight too " 97 << "large in\n"; 98 throw std::runtime_error(ss.str()); 99 } 100 average_(i) = av.mean(); 101 index_(i) = sum_w + 0.5*av.sum_w(); 102 sum_w += av.sum_w(); 103 } 104 } 105 106 59 107 const utility::Vector& qQuantileNormalizer::Partitioner::averages(void) const 60 108 {
Note: See TracChangeset
for help on using the changeset viewer.