Changeset 1735


Ignore:
Timestamp:
Jan 16, 2009, 10:33:53 PM (12 years ago)
Author:
Jari Häkkinen
Message:

Addresses #425. Taking care of some special cases. No iterative test is need.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/normalization_test.cc

    r1728 r1735  
    150150  // Enough iteration will make all columns to have the same values as
    151151  // the target.
    152   suite.err() << "Testing that iterative normalization works\n";
     152  suite.err() << "Testing that q=matrix rows gives QuantileNormaliztion\n";
    153153  utility::Matrix m2(4,2);
    154154  m2(0,0) = 0; m2(0,1) = 10;
     
    159159  utility::Matrix result2(m2.rows(),m2.columns());
    160160  qqn2(m2,result2);
    161   for (int d=0; d<50; ++d)
    162     qqn2(result2,result2);
    163161  suite.add( suite.equal_fix(m2(0,0),result2(2,1),1.0e-12) &&
    164162             suite.equal_fix(m2(1,0),result2(3,1),1.0e-12) &&
  • trunk/yat/normalizer/qQuantileNormalizer.cc

    r1731 r1735  
    5353      for (unsigned int r=start; r<end; ++r)
    5454        av.add(sortedvec(r));
    55       average_(i)=av.mean();
    56       index_(i)= static_cast<double>(end+start)/2;
     55      average_(i) = av.mean();
     56      index_(i)   = 0.5*(end+start-1);
    5757      start=end;
    5858    }
     
    109109      size_t start=0;
    110110      size_t end=static_cast<unsigned int>(idx(0));
    111       if (end<idx(0))
     111      // The first condition below takes care of limiting case number
     112      // of parts approximately equal to the number of matrix rows and
     113      // the second condition makes sure that index is larege enough
     114      // when using cspline below ... the static cast above takes the
     115      // floor whereas we want to take the "roof" forcing next index
     116      // range to be within interpolation range for the cspline.
     117      if ((end==0) || (end<idx(0)))
    112118        ++end;
    113119      for (size_t row=start; row<end; ++row) {
     
    116122      }
    117123
    118       // cspline interpolation for all data between the first and last
    119       // parts
     124      // cspline interpolation for all data between the mid points of
     125      // the first and last part
    120126      start=end;
    121127      end=static_cast<unsigned int>(idx(target_.size()-1));
     128      // take care of limiting case number of parts approximately
     129      // equal to the number of matrix rows
     130      if (end==(matrix.rows()-1))
     131        --end;
    122132      for (size_t row=start; row<=end; ++row) {
    123133        size_t srow=sorted_index[column][row];
Note: See TracChangeset for help on using the changeset viewer.