Welcome to mirror list, hosted at ThFree Co, Russian Federation.

time_samples.cpp « base - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3a0d439e185ac1c615ab054026653de7c16815cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "base/time_samples.hpp"

#include "std/cmath.hpp"

namespace my
{
void TimeSamples::Add(double s)
{
  m_s += s;
  m_s2 += s * s;
  ++m_total;
}

double TimeSamples::GetMean() const { return m_total == 0 ? 0.0 : m_s / m_total; }

double TimeSamples::GetSd() const
{
  if (m_total < 2)
    return 0.0;
  return std::max((m_s2 - m_s * m_s / static_cast<double>(m_total)) / (m_total - 1), 0.0);
}

double TimeSamples::GetVar() const { return sqrt(GetSd()); }
}  // namespace my