<commit_before>/**
 *  \file
 *  \remark This file is part of VITA.
 *
 *  \copyright Copyright (C) 2014 <NAME>.
 *
 *  \license
 *  This Source Code Form is subject to the terms of the Mozilla Public
 *  License, v. 2.0. If a copy of the MPL was not distributed with this file,
 *  You can obtain one at http://mozilla.org/MPL/2.0/
 */

#if !defined(VITA_DISTRIBUTION_INL_H)
#define      VITA_DISTRIBUTION_INL_H

///
/// Just the initial setup.
///
template<class T>
distribution<T>::distribution() : mean(), variance(), min(), max(), freq(),
                                  count_(0), m2_()
{
}

///
/// Resets gathered statics.
///
template<class T>
void distribution<T>::clear()
{
  *this = distribution();
}

///
/// \return Number of elements of the distribution.
///
template<class T>
std::uintmax_t distribution<T>::count() const
{
  return count_;
}

///
/// \brief Add a new value to the distribution
/// \param[in] val new value upon which statistics are recalculated.
///
template<class T>
void distribution<T>::add(T val)
{
  using std::isnan;

  if (!isnan(val))
  {
    if (!count())
      min = max = val;
    else if (val < min)
      min = val;
    else if (val > max)
      max = val;

    mean = val;
    ++count_;
<commit_msg>[FIX] Bug in distribution::add method<commit_after>/**
 *  \file
 *  \remark This file is part of VITA.
 *
 *  \copyright Copyright (C) 2014 <NAME>.
 *
 *  \license
 *  This Source Code Form is subject to the terms of the Mozilla Public
 *  License, v. 2.0. If a copy of the MPL was not distributed with this file,
 *  You can obtain one at http://mozilla.org/MPL/2.0/
 */

#if !defined(VITA_DISTRIBUTION_INL_H)
#define      VITA_DISTRIBUTION_INL_H

///
/// Just the initial setup.
///
template<class T>
distribution<T>::distribution() : mean(), variance(), min(), max(), freq(),
                                  count_(0), m2_()
{
}

///
/// Resets gathered statics.
///
template<class T>
void distribution<T>::clear()
{
  *this = distribution();
}

///
/// \return Number of elements of the distribution.
///
template<class T>
std::uintmax_t distribution<T>::count() const
{
  return count_;
}

///
/// \brief Add a new value to the distribution
/// \param[in] val new value upon which statistics are recalculated.
///
template<class T>
void distribution<T>::add(T val)
{
  using std::isnan;

  if (!isnan(val))
  {
    if (!count())
      min = max = mean = val;
    else if (val < min)
      min = val;
    else if (val > max)
      max = val;

    ++count_;

{'fraction_non_alphanumeric': 0.1547950656585754, 'fraction_numerical': 0.007958615200955034, 'mean_word_length': 2.5811965811965814, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4407799', 'n_tokens_mistral': 863, 'n_tokens_neox': 825, 'n_words': 275}