Ignore:
Timestamp:
Feb 6, 2009, 2:28:33 PM (12 years ago)
Author:
Peter
Message:

refs #478. Fixed so the tests for weighted qQN now are OK. To align
weighted and unweighted, I needed to change the definition of
index. The weighted index is more natural as the sum of weights with
value less than x plus half of the weight for x. The half of its own
weight part makes it quite symmetric. Anyway, for unity weights it
becomes, e.g, for a vector of size 4: 0.5, 1.5, 2.5, 3.5. Obviously
this doesnt change anything in the behavior since we are just adding a
0.5 to all index.

Also I decided to re-scale index inside the Partitioner, so the index
are now within range (0, 1).

Weighted version of normalize had to be implemented in itself and
could not use the unweighted because the weights come into play also
in this step.

I wanna test with a weighted range also as target, and when that works
I think we can close this ticket.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/normalization_test.cc

    r1775 r1778  
    193193 
    194194  using utility::DataWeight;
    195   // test with unweighted target and weighted source
     195  suite.err() << "Testing with unweighted target and weighted source\n";
    196196  std::vector<utility::DataWeight> src_w(source.size(), DataWeight(0, 1));
    197197  std::copy(source.begin(), source.end(),
     
    200200  std::vector<utility::DataWeight> result_w(src_w.size());
    201201  qQN(src_w.begin(), src_w.end(), result_w.begin());
    202   // FIXME: this test fails
    203   suite.xadd(suite.equal_range(result.begin(), result.end(),
     202  suite.add(suite.equal_range(result.begin(), result.end(),
    204203                              utility::data_iterator(result_w.begin())));
    205204
     205  suite.err() << "Testing with missing value in source\n";
    206206  // adding a missing value
    207207  src_w.insert(src_w.begin(), DataWeight(5.2, 0.0));
    208   result_w.resize(src_w.size());
    209   qQN(src_w.begin(), src_w.end(), result_w.begin());
     208  std::vector<utility::DataWeight> result_w2(src_w.size());
     209  qQN(src_w.begin(), src_w.end(), result_w2.begin());
    210210  // excluding missing value (result_w[0])
    211   suite.xadd(suite.equal_range(result.begin(), result.end(),
    212                               ++utility::data_iterator(result_w.begin())));
     211  suite.add(suite.equal_range(utility::data_iterator(result_w.begin()),
     212                               utility::data_iterator(result_w.end()),
     213                               ++utility::data_iterator(result_w2.begin())));
    213214}
    214215
Note: See TracChangeset for help on using the changeset viewer.