ProteoWizard
Classes | Functions
ralab::base::stats Namespace Reference

Classes

struct  NthPower
 

Functions

template<typename InputIterator >
std::iterator_traits< InputIterator >::value_type rootMeanSquare (const InputIterator begin, const InputIterator end)
 The root-mean-square for a column is obtained by computing the square-root of the sum-of-squares of the non-missing values in the column divided by the number of non-missing values minus one. More...
 
template<typename InputIterator >
void scale (InputIterator begin, InputIterator end, std::pair< typename std::iterator_traits< InputIterator >::value_type, typename std::iterator_traits< InputIterator >::value_type > &scaled, bool center=true, bool scale=true)
 scale centers and/or scales all values from begin in to end. More...
 

Function Documentation

§ rootMeanSquare()

template<typename InputIterator >
std::iterator_traits<InputIterator>::value_type ralab::base::stats::rootMeanSquare ( const InputIterator  begin,
const InputIterator  end 
)

The root-mean-square for a column is obtained by computing the square-root of the sum-of-squares of the non-missing values in the column divided by the number of non-missing values minus one.

Parameters
[in]beginstart iterator
[in]endend iterator

Definition at line 58 of file scale.hpp.

References x.

Referenced by scale().

62  {
63  typedef typename std::iterator_traits<InputIterator>::value_type TReal;
64  std::vector<TReal> x(begin,end);
65 
66  std::transform( x.begin(), x.end(), x.begin(), NthPower<2,TReal>() ); //first sqaure all elements
67  TReal sum = std::accumulate(x.begin(), x.end() , TReal(0.));
68  sum = sum/static_cast<TReal>(x.size() - size_t(1));
69  return(sqrt(sum));
70  }
KernelTraitsBase< Kernel >::space_type::abscissa_type x

§ scale()

template<typename InputIterator >
void ralab::base::stats::scale ( InputIterator  begin,
InputIterator  end,
std::pair< typename std::iterator_traits< InputIterator >::value_type, typename std::iterator_traits< InputIterator >::value_type > &  scaled,
bool  center = true,
bool  scale = true 
)

scale centers and/or scales all values from begin in to end.

Parameters
[out]scaledscaled.first = center, scaled.second = scale
[in]centereither a logical value or a numeric vector of length equal to the number of columns of x.
[in]scaleeither a logical value or a numeric vector of length equal to the number of columns of x.

Definition at line 77 of file scale.hpp.

References ralab::base::base::mean(), and rootMeanSquare().

Referenced by pwiz::util::almost_equal(), pwiz::frequency::TruncatedLorentzian::parameterCount(), and testParameterConversion().

84  {
85  typedef typename std::iterator_traits<InputIterator>::value_type TReal;
86  std::vector<TReal> tmp;
87 
88  if(center)
89  {
90  scaled.first = ralab::base::base::mean( begin , end);
91  std::transform(begin, end, begin, std::bind2nd( std::minus<TReal>(), scaled.first));
92  }
93  else
94  {
95  scaled.first = std::numeric_limits<TReal>::quiet_NaN();
96  }
97  if(scale)
98  {
99  scaled.second = rootMeanSquare( begin , end );
100  std::transform(begin, end, begin , std::bind2nd(std::divides<TReal>(), scaled.second) );
101  }
102  else
103  {
104  scaled.second = std::numeric_limits<TReal>::quiet_NaN();
105  }
106  }
std::iterator_traits< InputIterator >::value_type mean(InputIterator begin, InputIterator end)
MEAN Trimmed arithmetic mean.
Definition: base.hpp:187
void scale(InputIterator begin, InputIterator end, std::pair< typename std::iterator_traits< InputIterator >::value_type, typename std::iterator_traits< InputIterator >::value_type > &scaled, bool center=true, bool scale=true)
scale centers and/or scales all values from begin in to end.
Definition: scale.hpp:77
std::iterator_traits< InputIterator >::value_type rootMeanSquare(const InputIterator begin, const InputIterator end)
The root-mean-square for a column is obtained by computing the square-root of the sum-of-squares of t...
Definition: scale.hpp:58