/** * \file random_generator.h \brief random number generator * * Copyright 2007-2013 IMP Inventors. All rights reserved. * */ #ifndef IMPSTATISTICS_INTERNAL_HISTOGRAM_H #define IMPSTATISTICS_INTERNAL_HISTOGRAM_H #include #include #include IMPSTATISTICS_BEGIN_INTERNAL_NAMESPACE template struct MinMax { FloatPair minmax; MinMax(): minmax(std::numeric_limits::max(), -std::numeric_limits::max()) {} template void operator()(const G &g, const typename G::Index &i, const typename G::Vector &) { minmax.first=std::min(minmax.first, g[i]); minmax.second=std::max(minmax.second, g[i]); } }; template struct Mean { algebra::VectorD mn; Mean(algebra::VectorD start): mn(start){} template void operator()(const G &g, const typename G::Index &i, const typename G::Vector &v) { mn+=g[i]*v; } }; template struct Sigma2 { algebra::VectorD mn, sigma2; Sigma2(algebra::VectorD mn, algebra::VectorD start): mn(mn), sigma2(start) {} template void operator()(const G &g, const typename G::Index &index, const typename G::Vector &v) { if (g[index]!=0) { for (unsigned int i=0; i< mn.get_dimension(); ++i) { sigma2[i]+=g[index]*base::square(mn[i]-v[i]); } } } }; template struct Frequency { Grid &g_; double norm_; Frequency(Grid &g, double norm): g_(g), norm_(norm){} template void operator()(const G &g, const typename G::Index &index, const typename G::Vector &) { g_[index]=g[index]*norm_; } }; IMPSTATISTICS_END_INTERNAL_NAMESPACE #endif /* IMPSTATISTICS_INTERNAL_HISTOGRAM_H */