Changeset 3528
 Timestamp:
 Oct 11, 2016, 9:35:40 AM (7 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/statistics/AveragerWeighted.h
r2564 r3528 26 26 */ 27 27 28 #include "yat/utility/concept_check.h" 28 29 #include "yat/utility/iterator_traits.h" 29 30 … … 46 47 /// be more precise than others. The larger weight a measurement has 47 48 /// the more precise is is assumed to be, or more formally the 48 /// weight is proportional to the reciprocal variance 49 /// weight is proportional to the reciprocal variance 49 50 /// \f$ \sigma_i^2 = \frac{\sigma^2}{w_i} \f$. 2) Probability weights 50 51 /// are used for the situation when calculating averages over a … … 53 54 /// are taken to be \f$ \sum \frac{f}{f'}X \f$ For further discussion: 54 55 /// see \ref weighted_statistics 55 /// 56 /// 56 57 /// If nothing else stated, each function fulfills the 57 58 /// following:<br> <ul><li>Setting a weight to zero corresponds to … … 69 70 /// 70 71 /// @brief The default constructor 71 /// 72 /// 72 73 AveragerWeighted(void); 73 74 … … 83 84 84 85 /// 85 /// @brief Calculate the weighted mean 86 /// 87 /// @return \f$ \frac{\sum w_ix_i}{\sum w_i} \f$ 86 /// @brief Calculate the weighted mean 87 /// 88 /// @return \f$ \frac{\sum w_ix_i}{\sum w_i} \f$ 88 89 /// 89 90 double mean(void) const; 90 91 91 92 /// 92 /// @brief Weighted version of number of data points. 93 /// @brief Weighted version of number of data points. 93 94 /// 94 95 /// If all … … 99 100 /// 100 101 /// @return \f$ \frac{\left(\sum w_i\right)^2}{\sum w_i^2} \f$ 101 /// 102 /// 102 103 double n(void) const; 103 104 … … 130 131 /// approximation, use bootstrapping to estimate the error. 131 132 /// 132 /// @return \f$ \frac{\sum w^2}{\left(\sum w\right)^3}\sum w(xm)^2 \f$ 133 /// where \f$ m \f$ is the mean() 133 /// @return \f$ \frac{\sum w^2}{\left(\sum w\right)^3}\sum w(xm)^2 \f$ 134 /// where \f$ m \f$ is the mean() 134 135 /// 135 136 double standard_error(void) const; 136 137 137 138 /// 138 /// Calculating the sum of weights 139 /// Calculating the sum of weights 139 140 /// 140 141 /// @return \f$ \sum w_i \f$ … … 148 149 149 150 /// 150 /// \f$ \sum w_ix_i \f$ 151 /// \f$ \sum w_ix_i \f$ 151 152 /// 152 153 /// @return weighted sum of x … … 166 167 /** 167 168 The variance is calculated as \f$ \frac{\sum w_i (x_i  m)^2 168 }{\sum w_i} \f$, where \a m is the known mean. 169 169 }{\sum w_i} \f$, where \a m is the known mean. 170 170 171 @return Variance when the mean is known to be \a m. 171 172 */ … … 178 179 variance has no meaning as each data point has its own 179 180 variance. 180 181 181 182 @return The variance. 182 183 */ … … 189 190 */ 190 191 const AveragerWeighted& operator+=(const AveragerWeighted&); 191 192 192 193 private: 193 194 /// … … 200 201 /// 201 202 double sum_wwxx(void) const; 202 203 203 204 double mean_; // wx/w 204 205 double m2_; // wxx  m*m*w … … 217 218 If InputIterator is nonweighted unitary weights are used. 218 219 220 Type Requirement: 221  \c InputIterator models \ref concept_data_iterator 222  \c InputIterator is \single_pass_iterator 223 219 224 \relates AveragerWeighted 220 225 */ … … 222 227 void add(AveragerWeighted& a, InputIterator first, InputIterator last) 223 228 { 224 BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator>)); 229 BOOST_CONCEPT_ASSERT((utility::DataIteratorConcept<InputIterator>)); 230 BOOST_CONCEPT_ASSERT((boost_concepts::SinglePassIterator<InputIterator>)); 225 231 utility::iterator_traits<InputIterator> traits; 226 232 for ( ; first != last; ++first) … … 229 235 230 236 /** 231 \brief add values from two ranges to AveragerWeighted \a a 237 \brief add values from two ranges to AveragerWeighted \a a 232 238 233 239 Add data from range [first1, last1) with their corresponding 234 240 weight in range [first2, first2 + distance(first, last) ). 235 241 236 Requirement: InputIterator1 and InputIterator2 are unweighted 237 input iterators. 242 Type Requirement: 243  \c InputIterator1 models \single_pass_iterator 244  \c InputIterator1 models \readable_iterator 245  \c InputIterator1 is unweighted 246  \c InputIterator2 models \single_pass_iterator 247  \c InputIterator2 models \readable_iterator 248  \c InputIterator2 is unweighted 238 249 239 250 \relates AveragerWeighted 240 251 */ 241 252 template <typename InputIterator1, typename InputIterator2> 242 void add(AveragerWeighted& a, InputIterator1 first1, InputIterator1 last1, 253 void add(AveragerWeighted& a, InputIterator1 first1, InputIterator1 last1, 243 254 InputIterator2 first2) 244 255 { 245 BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator1>)); 246 BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator2>)); 256 BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIterator<InputIterator1>)); 257 BOOST_CONCEPT_ASSERT((boost_concepts::SinglePassIterator<InputIterator1>)); 258 BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIterator<InputIterator2>)); 259 BOOST_CONCEPT_ASSERT((boost_concepts::SinglePassIterator<InputIterator2>)); 260 247 261 utility::check_iterator_is_unweighted(first1); 248 262 utility::check_iterator_is_unweighted(first2);
Note: See TracChangeset
for help on using the changeset viewer.