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

Last change on this file since 1602 was 1575, checked in by Jari Häkkinen, 13 years ago

Added missing $ tag.

  • 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 1575 2008-10-14 07:19:48Z jari $
5
6/*
7  Copyright (C) 2008 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     \since New in yat 0.5
38   */
39  class Gauss
40  {
41  public:
42    /**
43       It is possible to centralize a range "in place"; it is
44       permissible for the iterators \a first and \a result to be the
45       same.
46
47       The range is first rank normalized using Spearman, after which
48       each element is between 0 and unity. Second each element is
49       replaced by inverse cumulative standard Gaussian distribution.
50       
51       After normalization the range will follow a standard Gaussian
52       distribution (mean zero and unity variance).
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.