Changeset 3528


Ignore:
Timestamp:
Oct 11, 2016, 9:35:40 AM (7 years ago)
Author:
Peter
Message:

refs #803. use new iterator concept in AveragerWeighted?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/statistics/AveragerWeighted.h

    r2564 r3528  
    2626*/
    2727
     28#include "yat/utility/concept_check.h"
    2829#include "yat/utility/iterator_traits.h"
    2930
     
    4647  /// be more precise than others. The larger weight a measurement has
    4748  /// 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
    4950  /// \f$ \sigma_i^2 = \frac{\sigma^2}{w_i} \f$. 2) Probability weights
    5051  /// are used for the situation when calculating averages over a
     
    5354  /// are taken to be \f$ \sum \frac{f}{f'}X \f$ For further discussion:
    5455  /// see \ref weighted_statistics
    55   /// 
     56  ///
    5657  /// If nothing else stated, each function fulfills the
    5758  /// following:<br> <ul><li>Setting a weight to zero corresponds to
     
    6970    ///
    7071    /// @brief The default constructor
    71     /// 
     72    ///
    7273    AveragerWeighted(void);
    7374
     
    8384
    8485    ///
    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$
    8889    ///
    8990    double mean(void) const;
    9091
    9192    ///
    92     /// @brief Weighted version of number of data points. 
     93    /// @brief Weighted version of number of data points.
    9394    ///
    9495    /// If all
     
    99100    ///
    100101    /// @return \f$ \frac{\left(\sum w_i\right)^2}{\sum w_i^2} \f$
    101     /// 
     102    ///
    102103    double n(void) const;
    103104
     
    130131    /// approximation, use bootstrapping to estimate the error.
    131132    ///
    132     /// @return \f$ \frac{\sum w^2}{\left(\sum w\right)^3}\sum w(x-m)^2 \f$ 
    133     /// where \f$ m \f$ is the mean() 
     133    /// @return \f$ \frac{\sum w^2}{\left(\sum w\right)^3}\sum w(x-m)^2 \f$
     134    /// where \f$ m \f$ is the mean()
    134135    ///
    135136    double standard_error(void) const;
    136137
    137138    ///
    138     /// Calculating the sum of weights 
     139    /// Calculating the sum of weights
    139140    ///
    140141    /// @return \f$ \sum w_i \f$
     
    148149
    149150    ///
    150     /// \f$ \sum w_ix_i \f$ 
     151    /// \f$ \sum w_ix_i \f$
    151152    ///
    152153    /// @return weighted sum of x
     
    166167    /**
    167168       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
    170171       @return Variance when the mean is known to be \a m.
    171172    */
     
    178179       variance has no meaning as each data point has its own
    179180       variance.
    180        
     181
    181182       @return The variance.
    182183    */
     
    189190    */
    190191    const AveragerWeighted& operator+=(const AveragerWeighted&);
    191    
     192
    192193  private:
    193194    ///
     
    200201    ///
    201202    double sum_wwxx(void) const;
    202    
     203
    203204    double mean_; // wx/w
    204205    double m2_; // wxx - m*m*w
     
    217218     If InputIterator is non-weighted unitary weights are used.
    218219
     220     Type Requirement:
     221     - \c InputIterator models \ref concept_data_iterator
     222     - \c InputIterator is \single_pass_iterator
     223
    219224     \relates AveragerWeighted
    220225   */
     
    222227  void add(AveragerWeighted& a, InputIterator first, InputIterator last)
    223228  {
    224     BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator>));
     229    BOOST_CONCEPT_ASSERT((utility::DataIteratorConcept<InputIterator>));
     230    BOOST_CONCEPT_ASSERT((boost_concepts::SinglePassIterator<InputIterator>));
    225231    utility::iterator_traits<InputIterator> traits;
    226232    for ( ; first != last; ++first)
     
    229235
    230236  /**
    231      \brief add values from two ranges to AveragerWeighted \a a 
     237     \brief add values from two ranges to AveragerWeighted \a a
    232238
    233239     Add data from range [first1, last1) with their corresponding
    234240     weight in range [first2, first2 + distance(first, last) ).
    235241
    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
    238249
    239250     \relates AveragerWeighted
    240251   */
    241252  template <typename InputIterator1, typename InputIterator2>
    242   void add(AveragerWeighted& a, InputIterator1 first1, InputIterator1 last1, 
     253  void add(AveragerWeighted& a, InputIterator1 first1, InputIterator1 last1,
    243254           InputIterator2 first2)
    244255  {
    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
    247261    utility::check_iterator_is_unweighted(first1);
    248262    utility::check_iterator_is_unweighted(first2);
Note: See TracChangeset for help on using the changeset viewer.