<commit_before>// __BEGIN_LICENSE__
// Copyright (C) 2006-2009 United States Government as represented by
// the Administrator of the National Aeronautics and Space Administration.
// All Rights Reserved.
// __END_LICENSE__


#include <gtest/gtest.h>
#include <vw/Math/Functors.h>
#include <boost/random.hpp>

using namespace vw;
using namespace vw::math;

static const double DELTA = 1e-5;

TEST(Accumulators, CDF_cauchy) {
  CDFAccumulator<double> cdf;

  boost::minstd_rand random_gen(42u);
  random_gen.seed((unsigned int)(std::time(0)));
  boost::cauchy_distribution<double> cauchy(35,80);
  boost::variate_generator<boost::minstd_rand, boost::cauchy_distribution<double> > generator(random_gen, cauchy);

  for ( uint i = 0; i < 50000; i++ )
    cdf( generator() );

  std::cout << "CDF Median: " << cdf.median() << "\n";

  EXPECT_NEAR( cdf.median(), 35.0, 2.0 );
  EXPECT_NEAR( cdf.first_quartile(), -45, 4.0 );
  EXPECT_NEAR( cdf.third_quartile(), 115, 4.0 );
}

TEST(Accumulators, CDF_triangular) {
  CDFAccumulator<double> cdf;

  boost::minstd_rand random_gen(42u);
  random_gen.seed((unsigned int)(std::time(0)));
  boost::triangle_distribution<double> triangular(10,60,80);
  boost::variate_generator<boost::minstd_rand, boost::triangle_distribution<double> > generator(random_gen, triangular);

  for ( uint i = 0; i < 50000; i++ )
    cdf( generator() );

  EXPECT_NEAR( cdf.median(), 51.833, 1.0 );
  EXPECT_NEAR( cdf.first_quartile(), 39.6, 2.0 );
  EXPECT_NEAR( cdf.third_quartile(), 61.3, 2.0 );
}

TEST(Accumulators, Median) {
  MedianAccumulator<double> median;

  boost::minstd_rand random_gen(42u);
  random_gen.seed((unsigned int)(std::time(0)));
  boost::cauchy_distribution<double> cauchy(35,80);
  boost::variate_generator<boost::minstd_rand, boost::cauchy_distribution<double> > generator(random_gen, cauchy);

  for ( uint i = 0; i < 50000; i++ )
    median( generator() );

  EXPECT_NEAR( median.value(), 35.0, 1.5 );
}
<commit_msg>time is global, not standard<commit_after>// __BEGIN_LICENSE__
// Copyright (C) 2006-2009 United States Government as represented by
// the Administrator of the National Aeronautics and Space Administration.
// All Rights Reserved.
// __END_LICENSE__


#include <gtest/gtest.h>
#include <vw/Math/Functors.h>
#include <boost/random.hpp>

using namespace vw;
using namespace vw::math;

static const double DELTA = 1e-5;

TEST(Accumulators, CDF_cauchy) {
  CDFAccumulator<double> cdf;

  boost::minstd_rand random_gen(42u);
  random_gen.seed((unsigned int)(::time(0)));
  boost::cauchy_distribution<double> cauchy(35,80);
  boost::variate_generator<boost::minstd_rand, boost::cauchy_distribution<double> > generator(random_gen, cauchy);

  for ( uint i = 0; i < 50000; i++ )
    cdf( generator() );

  std::cout << "CDF Median: " << cdf.median() << "\n";

  EXPECT_NEAR( cdf.median(), 35.0, 2.0 );
  EXPECT_NEAR( cdf.first_quartile(), -45, 4.0 );
  EXPECT_NEAR( cdf.third_quartile(), 115, 4.0 );
}

TEST(Accumulators, CDF_triangular) {
  CDFAccumulator<double> cdf;

  boost::minstd_rand random_gen(42u);
  random_gen.seed((unsigned int)(::time(0)));
  boost::triangle_distribution<double> triangular(10,60,80);
  boost::variate_generator<boost::minstd_rand, boost::triangle_distribution<double> > generator(random_gen, triangular);

  for ( uint i = 0; i < 50000; i++ )
    cdf( generator() );

  EXPECT_NEAR( cdf.median(), 51.833, 1.0 );
  EXPECT_NEAR( cdf.first_quartile(), 39.6, 2.0 );
  EXPECT_NEAR( cdf.third_quartile(), 61.3, 2.0 );
}

TEST(Accumulators, Median) {
  MedianAccumulator<double> median;

  boost::minstd_rand random_gen(42u);
  random_gen.seed((unsigned int)(::time(0)));
  boost::cauchy_distribution<double> cauchy(35,80);
  boost::variate_generator<boost::minstd_rand, boost::cauchy_distribution<double> > generator(random_gen, cauchy);

  for ( uint i = 0; i < 50000; i++ )
    median( generator() );

  EXPECT_NEAR( median.value(), 35.0, 1.5 );
}

{'fraction_non_alphanumeric': 0.15895218718209564, 'fraction_numerical': 0.04425228891149542, 'mean_word_length': 5.2928, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5549239', 'n_tokens_mistral': 1615, 'n_tokens_neox': 1418, 'n_words': 290}