File: scipy_issue_17388.cpp

package info (click to toggle)
boost1.90 1.90.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 593,156 kB
  • sloc: cpp: 4,190,642; xml: 196,648; python: 34,618; ansic: 23,145; asm: 5,468; sh: 3,776; makefile: 1,161; perl: 1,020; sql: 728; ruby: 676; yacc: 478; java: 77; lisp: 24; csh: 6
file content (27 lines) | stat: -rw-r--r-- 1,108 bytes parent folder | download | duplicates (10)
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();
}