Changeset 4048
- Timestamp:
- Mar 3, 2021, 1:39:31 PM (2 years ago)
- Location:
- trunk/yat/normalizer
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/normalizer/Makefile.am
r3999 r4048 21 21 yat_libyat_la_SOURCES += \ 22 22 yat/normalizer/qQuantileNormalizer.cc \ 23 yat/normalizer/QuantileNormalizer.cc 23 yat/normalizer/QuantileNormalizer.cc \ 24 yat/normalizer/Zscore.cc 24 25 25 26 nobase_include_HEADERS += \ -
trunk/yat/normalizer/Zscore.h
r3550 r4048 42 42 43 43 Shift and scale the values in a range as: \f$ y_i = 44 \frac{x_i-m}{s} \f$ where \a m is the mean and \a s is the 45 standard deviation. After normalization, the range will have zero 46 mean and unity variance. 44 \frac{x_i-m}{k*s} \f$ where \a m is the mean, \a s is the 45 standard deviation, and \a k is set in constructor (default: 46 1.0). After normalization, the range will have zero mean and 47 variance = \f$ 1/k^2 \f$. 47 48 48 49 Type Requirements: … … 57 58 { 58 59 public: 60 /** 61 \param k In the scaling step elements are divided by \c k times 62 the standard deviation 63 64 \since New in yat 0.19 65 */ 66 Zscore(double k=1.0); 67 68 /** 69 \return the k-factor set in constructor 70 71 \since new in yat 0.19 72 */ 73 double k(void) const; 74 59 75 /** 60 76 The element in range [result, result + (last-first)) is … … 80 96 81 97 private: 98 double k_; 99 100 82 101 template<class ForwardIterator, class OutputIterator> 83 102 void normalize(ForwardIterator first, ForwardIterator last, … … 95 114 add(a, first, last); 96 115 double m = a.mean(); 97 double std = a.std();116 double factor = 1.0 / (a.std() * k_); 98 117 while (first!=last) { 99 *result = (*first - m) / std;118 *result = (*first - m) * factor; 100 119 ++first; 101 120 ++result; … … 120 139 add(a, first, last); 121 140 double m = a.mean(); 122 double std = a.std();141 double factor = 1.0 / (a.std() * k_); 123 142 utility::iterator_traits<ForwardIterator> in_trait; 124 143 utility::iterator_traits<OutputIterator> out_trait; 125 144 while (first!=last) { 126 out_trait.data(result) = (in_trait.data(first) - m) / std;145 out_trait.data(result) = (in_trait.data(first) - m) * factor; 127 146 ++first; 128 147 ++result;
Note: See TracChangeset
for help on using the changeset viewer.