File: scipy_issue_17388.cpp

package info (click to toggle)
scipy 1.17.0-1exp2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 235,340 kB
  • sloc: cpp: 506,914; python: 357,038; ansic: 215,028; javascript: 89,566; fortran: 19,308; cs: 3,081; f90: 1,150; sh: 860; makefile: 519; pascal: 284; lisp: 134; xml: 56; perl: 51
file content (27 lines) | stat: -rw-r--r-- 1,108 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright Matt Borland, 2022
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// See: https://github.com/boostorg/math/issues/889
// See: https://github.com/scipy/scipy/issues/17388

#include <array>
#include <numeric>
#include <boost/math/distributions/binomial.hpp>
#include "math_unit_test.hpp"

int main(void)
{
    // Test case 1: Goes against scipy convention but is correct
    const auto binom_dist_1 {boost::math::binomial_distribution<double>(4, 0.5)};
    // https://www.wolframalpha.com/input?i=quantile%28binomial+distribution%284%2C0.5%29%2C0%29
    CHECK_ULP_CLOSE(boost::math::quantile(binom_dist_1, 0.0), 0.0, 1);
    
    // Test case 2 from linked issue
    const auto binom_dist_2 {boost::math::binomial_distribution<double>(4, 1)};
    // https://www.wolframalpha.com/input?i=quantile%28binomial+distribution%284%2C1%29%2C0.3%29
    CHECK_ULP_CLOSE(4.0, boost::math::quantile(binom_dist_2, 0.3), 1);

    return boost::math::test::report_errors();
}