35 #ifndef OPENMS_ANALYSIS_OPENSWATH_OPENSWATHALGO_ALGO_STATSHELPERS_H 36 #define OPENMS_ANALYSIS_OPENSWATH_OPENSWATHALGO_ALGO_STATSHELPERS_H 38 #include <OpenMS/ANALYSIS/OPENSWATH/OPENSWATHALGO/OpenSwathAlgoConfig.h> 52 OPENSWATHALGO_DLLAPI
void normalize(
const std::vector<double>& intensities,
double normalization_factor, std::vector<double>& normalized_intensities);
61 for (; beg != end; ++beg)
70 std::unary_function<double, double>
82 template <
typename Texp,
typename Ttheo>
83 double dotProd(Texp intExpBeg, Texp intExpEnd, Ttheo intTheo)
85 std::vector<double> res(std::distance(intExpBeg, intExpEnd));
86 std::transform(intExpBeg, intExpEnd, intTheo, res.begin(), std::multiplies<double>());
87 double sum = std::accumulate(res.begin(), res.end(), 0.);
98 OPENSWATHALGO_DLLAPI
double dotprodScoring(std::vector<double> intExp, std::vector<double> theorint);
103 template <
typename Texp,
typename Ttheo>
107 for (std::size_t i = 0; itExpBeg < itExpEnd; ++itExpBeg, ++itTheo, ++i)
109 double x = *itExpBeg - *itTheo;
123 OPENSWATHALGO_DLLAPI
double manhattanScoring(std::vector<double> intExp, std::vector<double> theorint);
129 template <
typename TInputIterator,
typename TInputIteratorY>
130 typename std::iterator_traits<TInputIterator>::value_type
cor_pearson(
136 typedef typename std::iterator_traits<TInputIterator>::value_type value_type;
140 m1 = m2 = s1 = s2 = 0.0;
142 ptrdiff_t n = std::distance(xBeg, xEnd);
143 value_type nd =
static_cast<value_type
>(n);
144 for (; xBeg != xEnd; ++xBeg, ++yBeg)
146 corr += *xBeg * *yBeg;
157 if (s1 < 1.0e-12 || s2 < 1.0e-12)
161 corr -= m1 * m2 * (
double)n;
162 corr /= sqrt(s1 * s2);
177 m_(0.0), q_(0.0), c_(0u)
183 double const delta = sample - m_;
185 q_ += delta * (sample - m_);
190 return (c_ > 1u) ? (q_ / (c_ - 1)) : 0;
195 return (c_ > 1u) ? (q_ / c_) : 0;
200 return std::sqrt(sample_variance());
205 return std::sqrt(standard_variance());
220 return sample_variance();
225 return sample_stddev();
237 #endif // OPENMS_ANALYSIS_OPENSWATH_OPENSWATHALGO_ALGO_STATSHELPERS_H double standard_variance() const
Definition: StatsHelpers.h:193
double standard_stddev() const
Definition: StatsHelpers.h:203
double manhattanDist(Texp itExpBeg, Texp itExpEnd, Ttheo itTheo)
compute manhattan distance between Exp and Theo
Definition: StatsHelpers.h:104
OPENSWATHALGO_DLLAPI double manhattanScoring(std::vector< double > intExp, std::vector< double > theorint)
manhattan scoring
static double sum(IteratorType begin, IteratorType end)
Calculates the sum of a range of values.
Definition: StatisticFunctions.h:122
double mean() const
Definition: StatsHelpers.h:208
OPENSWATHALGO_DLLAPI double dotprodScoring(std::vector< double > intExp, std::vector< double > theorint)
the dot product scoring
void operator()(double sample)
Definition: StatsHelpers.h:181
double sample_stddev() const
Definition: StatsHelpers.h:198
OPENSWATHALGO_DLLAPI void normalize(const std::vector< double > &intensities, double normalization_factor, std::vector< double > &normalized_intensities)
Normalize intensities in vector by normalization_factor.
unsigned long c_
Definition: StatsHelpers.h:173
mean_and_stddev()
Definition: StatsHelpers.h:176
double q_
Definition: StatsHelpers.h:172
unsigned long count() const
Definition: StatsHelpers.h:213
Definition: MRMScoring.h:51
Definition: StatsHelpers.h:69
functor to compute the mean and stddev of sequence using the std::foreach algorithm ...
Definition: StatsHelpers.h:170
std::iterator_traits< TInputIterator >::value_type cor_pearson(TInputIterator xBeg, TInputIterator xEnd, TInputIteratorY yBeg)
compute pearson correlation of vector x and y
Definition: StatsHelpers.h:130
double sample_variance() const
Definition: StatsHelpers.h:188
double norm(T beg, T end)
compute the norm of the vector
Definition: StatsHelpers.h:58
double stddev() const
Definition: StatsHelpers.h:223
double dotProd(Texp intExpBeg, Texp intExpEnd, Ttheo intTheo)
compute dotprod of vectors
Definition: StatsHelpers.h:83
double operator()() const
Definition: StatsHelpers.h:228
double result_type
Definition: StatsHelpers.h:175
double operator()(double x)
Definition: StatsHelpers.h:72
double variance() const
Definition: StatsHelpers.h:218