Changeset 1050


Ignore:
Timestamp:
May 6, 2009, 11:11:59 AM (12 years ago)
Author:
Jari Häkkinen
Message:

Addresses #118. Non-logged input values are expected, geometric mean is used for averaging.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/base2/net.sf.basedb.normalizers/trunk/src/c++/bin/qQN.cc

    r1049 r1050  
    4343using namespace theplu::yat::utility;
    4444
     45
    4546void create_target_and_fix_nans(std::vector<double>&, MatrixWeighted&);
    4647void create_target_and_fix_nans(std::vector<double>&, MatrixWeighted&,
    4748                                const std::string&);
     49
     50void exp_numbers(MatrixWeighted&);
     51template<typename Iterator> void log_numbers(Iterator first, Iterator last);
     52void log_numbers(MatrixWeighted&);
     53
    4854/**
    4955   writes the data values in the matrix ignoring the weights, i.e.,
     
    102108  ( assay.present() ? create_target_and_fix_nans(target,m,assay.value()) :
    103109                      create_target_and_fix_nans(target,m) );
     110  log_numbers(target.begin(),target.end());
     111  log_numbers(m);
    104112  qQuantileNormalizer qqn(target.begin(), target.end(), 100);
    105113  ColumnNormalizer<qQuantileNormalizer> cn(qqn);
    106114  MatrixWeighted result(m.rows(),m.columns());
    107115  cn(m,result);
     116  exp_numbers(result);
    108117
    109118  std::ofstream* outfile=NULL;
     
    186195
    187196
     197void exp_numbers(MatrixWeighted& m)
     198{
     199  MatrixWeighted::iterator i=m.begin();
     200  while (i!=m.end()) {
     201    i->data() =std::exp(i->data());
     202    ++i;
     203  }
     204}
     205
     206
     207template<typename Iterator> void log_numbers(Iterator i, Iterator last)
     208{
     209  while (i!=last) {
     210    *i=std::log(*i);
     211    ++i;
     212  }
     213}
     214
     215
     216void log_numbers(MatrixWeighted& m)
     217{
     218  MatrixWeighted::iterator i=m.begin();
     219  while (i!=m.end()) {
     220    i->data() =std::log(i->data());
     221    ++i;
     222  }
     223}
     224
     225
    188226std::ostream& operator<< (std::ostream& s, const MatrixWeighted& m)
    189227{
Note: See TracChangeset for help on using the changeset viewer.