Changeset 4048 for trunk/yat/normalizer/Zscore.h
 Timestamp:
 Mar 3, 2021, 1:39:31 PM (2 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

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_im}{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_im}{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 kfactor 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 + (lastfirst)) 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.