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

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

fixes #479 and removing some debug output

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1#ifndef _theplu_yat_normalizer_gauss_
2#define _theplu_yat_normalizer_gauss_
3
4// $Id: Gauss.h 1739 2009-01-21 01:34:18Z 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    template<typename ForwardIterator, typename RandomAccessIterator>
57    void operator()(ForwardIterator first, ForwardIterator last,
58                    RandomAccessIterator result) const
59    {
60      Spearman spearman;
61      spearman(first, last, result);
62      RandomAccessIterator end = result + (last-first);
63      utility::iterator_traits<RandomAccessIterator> trait;
64      while (result != end) {
65        trait.data(result) = gsl_cdf_ugaussian_Pinv(trait.data(result));
66        ++result;
67      }
68    }
69
70
71  private:
72  };
73
74}}} // end of namespace normalizer, yat and thep
75#endif
Note: See TracBrowser for help on using the repository browser.