<commit_before>#include <stan/math/prim.hpp>
#include <stan/math/prim/fun/constants.hpp>
#include <gtest/gtest.h>

TEST(ProbVonMises, pdf_cdf_agree_test) {
  using stan::math::von_mises_cdf;
  using stan::math::von_mises_lpdf;
  double sum, t, y;
  std::vector<double> ts, ys;
  double abs_tol_int = 1e-4;

  // set random parameter values
  double mu = 0.1;
  double k = 6;

  // tabulate pdf at equispaced nodes
  int n = 1000;
  double xmin = -0.2;
  double xmax = 0.3;
  for(int i=0; i<n; i++) {
    t = xmin + i * (xmax - xmin) / (n - 1);
    ts.push_back(t);

    y = exp(von_mises_lpdf(t, mu, k));
    ys.push_back(y);
  }

  // integrate pdf numerically with trapezoid rule
  sum = ys[0] / 2 + ys[n-1] / 2;
  for(int i=1; i<n - 1; i++) {
    sum += ys[i];
  }
  sum = sum / ((n-1) / (xmax - xmin));

  // and compare to cdf
  double val2 = von_mises_cdf(xmax, mu, k) - von_mises_cdf(xmin, mu, k);

  ASSERT_NEAR(val2, sum, abs_tol_int);
}


TEST(ProbVonMises, pointwise_cdf_test) {
  using stan::math::von_mises_cdf;
  double pi = stan::math::pi();
  // check that our von_mises_cdf coincides with scipy's
  double ABS_TOL = 1e-12;
  ASSERT_NEAR(0.0000157567385742, von_mises_cdf(-3.141492653589793, 0, 0.01),
              ABS_TOL);
  ASSERT_NEAR(0.0000157567385742,
              von_mises_cdf(-3.141492653589793, 6.283185307179586, 0.01),
              ABS_TOL);
  ASSERT_NEAR(0.0000157567385742,
              von_mises_cdf(-3.141492653589793, -6.283185307179586, 0.01),
              ABS_TOL);
  ASSERT_NEAR(0.2484164302237636, von_mises_cdf(-1.5707463267948965, 0, 0.01),
              ABS_TOL);<commit_msg>[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.04.1 (tags/RELEASE_600/final)<commit_after>#include <stan/math/prim.hpp>
#include <stan/math/prim/fun/constants.hpp>
#include <gtest/gtest.h>

TEST(ProbVonMises, pdf_cdf_agree_test) {
  using stan::math::von_mises_cdf;
  using stan::math::von_mises_lpdf;
  double sum, t, y;
  std::vector<double> ts, ys;
  double abs_tol_int = 1e-4;

  // set random parameter values
  double mu = 0.1;
  double k = 6;

  // tabulate pdf at equispaced nodes
  int n = 1000;
  double xmin = -0.2;
  double xmax = 0.3;
  for (int i = 0; i < n; i++) {
    t = xmin + i * (xmax - xmin) / (n - 1);
    ts.push_back(t);

    y = exp(von_mises_lpdf(t, mu, k));
    ys.push_back(y);
  }

  // integrate pdf numerically with trapezoid rule
  sum = ys[0] / 2 + ys[n - 1] / 2;
  for (int i = 1; i < n - 1; i++) {
    sum += ys[i];
  }
  sum = sum / ((n - 1) / (xmax - xmin));

  // and compare to cdf
  double val2 = von_mises_cdf(xmax, mu, k) - von_mises_cdf(xmin, mu, k);

  ASSERT_NEAR(val2, sum, abs_tol_int);
}

TEST(ProbVonMises, pointwise_cdf_test) {
  using stan::math::von_mises_cdf;
  double pi = stan::math::pi();
  // check that our von_mises_cdf coincides with scipy's
  double ABS_TOL = 1e-12;
  ASSERT_NEAR(0.0000157567385742, von_mises_cdf(-3.141492653589793, 0, 0.01),
              ABS_TOL);
  ASSERT_NEAR(0.0000157567385742,
              von_mises_cdf(-3.141492653589793, 6.283185307179586, 0.01),
              ABS_TOL);
  ASSERT_NEAR(0.0000157567385742,
              von_mises_cdf(-3.141492653589793, -6.283185307179586, 0.01),
              ABS_TOL);
  ASSERT_NEAR(0.2484164302237636, von_mises_cdf(-1.5707463267948965, 0, 0.01),
              ABS_TOL);
{'fraction_non_alphanumeric': 0.14794848757112908, 'fraction_numerical': 0.12728361784965558, 'mean_word_length': 2.9526627218934913, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, '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': '1880543', 'n_tokens_mistral': 1744, 'n_tokens_neox': 1469, 'n_words': 289}