source: trunk/yat/normalizer/Gauss.h @ 1717

Last change on this file since 1717 was 1717, checked in by Peter, 12 years ago

improved(?) docs. Moved some docs from operator() to class docs.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1#ifndef _theplu_yat_normalizer_gauss_
2#define _theplu_yat_normalizer_gauss_
3
4// $Id: Gauss.h 1717 2009-01-13 22:32:00Z peter $
5
6/*
7  Copyright (C) 2008, 2009 Peter Johansson
8
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25#include "Spearman.h"
26#include "yat/utility/iterator_traits.h"
27
28#include <gsl/gsl_cdf.h>
29
30namespace theplu {
31namespace yat {
32namespace normalizer {
33
34  /**
35     \brief Gaussian Normalizer
36
37     After normalization the range will follow a standard Gaussian
38     distribution (mean zero and unity variance).
39     
40     The range is first rank normalized using Spearman, after which
41     each element is between 0 and unity. Second each element is
42     replaced by inverse cumulative standard Gaussian distribution.
43     
44     \since New in yat 0.5
45   */
46  class Gauss
47  {
48  public:
49    /**
50       It is possible to centralize a range "in place"; it is
51       permissible for the iterators \a first and \a result to be the
52       same.
53
54       \see gsl_cdf_ugaussian_Pinv
55
56       \return result + (last-first)
57     */
58    template<typename ForwardIterator, typename RandomAccessIterator>
59    RandomAccessIterator operator()(ForwardIterator first, ForwardIterator last,
60                                    RandomAccessIterator result) const
61    {
62      Spearman spearman;
63      spearman(first, last, result);
64      RandomAccessIterator end = result + (last-first);
65      utility::iterator_traits<RandomAccessIterator> trait;
66      while (result != end) {
67        trait.data(result) = gsl_cdf_ugaussian_Pinv(trait.data(result));
68        ++result;
69      }
70     
71      return result;
72    }
73
74
75  private:
76  };
77
78}}} // end of namespace normalizer, yat and thep
79#endif
Note: See TracBrowser for help on using the repository browser.