Changeset 1737


Ignore:
Timestamp:
Jan 19, 2009, 9:40:06 PM (12 years ago)
Author:
Peter
Message:

addresses #478 - preparing for weighted version

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/normalization_test.cc

    r1736 r1737  
    4646void test_gauss_normalize(test::Suite&);
    4747void test_qquantile_normalize(test::Suite&);
     48void test_qquantile_normalize_weighted(test::Suite&);
    4849void test_quantile_normalize(test::Suite&);
    4950void test_row_normalize(test::Suite&);
     
    6061  test_column_normalize(suite);
    6162  test_qquantile_normalize(suite);
     63  test_qquantile_normalize_weighted(suite);
    6264  test_quantile_normalize(suite);
    6365  test_gauss_normalize(suite);
     
    165167             suite.equal_fix(m2(2,0),result2(1,1),1.0e-12) &&
    166168             suite.equal_fix(m2(3,0),result2(0,1),1.0e-12) );
     169}
     170
     171
     172void test_qquantile_normalize_weighted(test::Suite& suite)
     173{
     174  using namespace normalizer;
     175
     176  suite.err() << "Testing qQuantileNormalizer weighted\n";
     177
     178  std::vector<utility::DataWeight> vec;
     179  vec.reserve(100);
     180  for (size_t i=0; i<100; ++i)
     181    vec.push_back(utility::DataWeight(i, 1.0));
     182  //qQuantileNormalizer(vec.begin(), vec.end(), 5);
    167183}
    168184
  • trunk/yat/normalizer/qQuantileNormalizer.h

    r1736 r1737  
    2222
    2323#include "yat/regression/CSplineInterpolation.h"
     24#include "yat/utility/DataWeight.h"
     25#include "yat/utility/iterator_traits.h"
    2426#include "yat/utility/Vector.h"
    2527#include "yat/utility/yat_assert.h"
     
    2830#include <iterator>
    2931#include <stdexcept>
     32#include <vector>
    3033
    3134namespace theplu {
     
    139142
    140143  private:
     144    // unweighted "constructor"
     145    template<typename Iterator>
     146    void build(Iterator first, Iterator last, unsigned int N,
     147               utility::unweighted_iterator_tag);
    141148    void init(const utility::VectorBase&, unsigned int N);
    142149
     
    230237    : average_(utility::Vector(N)), index_(utility::Vector(N))
    231238  {
     239    typedef typename
     240      utility::weighted_iterator_traits<BidirectionalIterator>::type tag;
     241    build(first, last, N, tag());
     242         
     243  }
     244
     245
     246  template<typename Iterator>
     247  void qQuantileNormalizer::Partitioner::build(Iterator first, Iterator last,
     248                                               unsigned int N,
     249                                               utility::unweighted_iterator_tag)
     250  {
    232251    utility::Vector vec(std::distance(first, last));
    233252    std::copy(first, last, vec.begin());
Note: See TracChangeset for help on using the changeset viewer.