#ifndef _theplu_yat_normalizer_gauss_
#define _theplu_yat_normalizer_gauss_
/*
Copyright (C) 2008 Peter Johansson
This file is part of the yat library, http://dev.thep.lu.se/yat
The yat library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3 of the
License, or (at your option) any later version.
The yat library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with yat. If not, see .
*/
#include "Spearman.h"
#include "yat/utility/iterator_traits.h"
#include
namespace theplu {
namespace yat {
namespace normalizer {
/**
\brief Gaussian Normalizer
\since New in yat 0.5
*/
class Gauss
{
public:
/**
It is possible to centralize a range "in place"; it is
permissible for the iterators \a first and \a result to be the
same.
The range is first rank normalized using Spearman, after which
each element is between 0 and unity. Second each element is
replaced by inverse cumulative standard Gaussian distribution.
After normalization the range will follow a standard Gaussian
distribution (mean zero and unity variance).
\see gsl_cdf_ugaussian_Pinv
\return result + (last-first)
*/
template
RandomAccessIterator operator()(ForwardIterator first, ForwardIterator last,
RandomAccessIterator result) const
{
Spearman spearman;
spearman(first, last, result);
RandomAccessIterator end = result + (last-first);
utility::iterator_traits trait;
while (result != end) {
trait.data(result) = gsl_cdf_ugaussian_Pinv(trait.data(result));
++result;
}
return result;
}
private:
};
}}} // end of namespace normalizer, yat and thep
#endif