Changeset 1518
- Timestamp:
- Sep 21, 2008, 6:07:45 AM (14 years ago)
- Location:
- trunk/yat/normalizer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/normalizer/ColumnNormalizer.h
r1498 r1518 22 22 23 23 #include "yat/utility/Matrix.h" 24 #include "yat/utility/yat_assert.h" 25 26 #include <stdexcept> 24 27 25 28 namespace theplu { … … 55 58 56 59 /** 57 Each column in \a result is normalized using class T. 60 Each column in \a matrix is normalized using class T, and 61 assigned to Matrix \a result. 58 62 59 \note matrix is ignored63 \note \a result must have same dimensions as \a matrix. 60 64 */ 61 65 void operator()(const utility::Matrix& matrix, … … 69 73 utility::Matrix& result) const 70 74 { 75 using utility::yat_assert; 76 yat_assert<std::runtime_error>(matrix.rows()==result.rows(), 77 "ColumnNormalizer: rows mismatch"); 78 yat_assert<std::runtime_error>(matrix.columns()==result.columns(), 79 "ColumnNormalizer: columns mismatch"); 71 80 for (size_t i=0; i<matrix.columns(); ++i) 72 normalizer_( result.begin_column(i), result.end_column(i),81 normalizer_(matrix.begin_column(i), matrix.end_column(i), 73 82 result.begin_column(i)); 74 83 -
trunk/yat/normalizer/QuantileNormalizer.cc
r1497 r1518 39 39 { 40 40 assert(data.rows()==result.rows()); 41 assert(data.columns()==result.columns()); 42 43 // create a tmp copy 41 44 utility::Matrix data_copy(data); 42 45 … … 48 51 // calculate average of each row 49 52 std::vector<yat::statistics::Averager> averager(data_copy.rows()); 50 for (size_t row=0; row< data_copy.rows(); ++row){53 for (size_t row=0; row<result.rows(); ++row){ 51 54 add(averager[row], data_copy.begin_row(row), data_copy.end_row(row)); 52 55 } … … 54 57 for (size_t column=0; column<result.columns(); ++column){ 55 58 std::vector<size_t> index; 56 utility::sort_index(index, result.column_const_view(column));59 utility::sort_index(index, data.column_const_view(column)); 57 60 58 for (size_t row=0; row< result.rows(); ++row)61 for (size_t row=0; row<data.rows(); ++row) 59 62 result(index[row], column) = averager[row].mean(); 60 63 } -
trunk/yat/normalizer/QuantileNormalizer.h
r1497 r1518 29 29 30 30 /** 31 \brief Perform quantile normaliz er31 \brief Perform quantile normalization 32 32 33 33 \since New in yat 0.5 … … 39 39 The \a matrix is normalized by sorting each column, replacing 40 40 each value with the average across rows, and undo the sorting 41 in step 1. This results in a \a matrix in which each column has42 the same distribution of data, and the rank of an element43 within a column is preserved in the normalizer.41 in step 1. This results in a Matrix \a result in which each 42 column has the same distribution of data, and the rank of an 43 element within a column is the same as in \a matrix. 44 44 45 \note Number of rows in\a matrix and \a result must match.45 \note dimensions of \a matrix and \a result must match. 46 46 */ 47 void operator()(const utility::Matrix& matrix, 47 void operator()(const utility::Matrix& matrix, 48 48 utility::Matrix& result) const; 49 49 };
Note: See TracChangeset
for help on using the changeset viewer.