2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-25 06:22:09 +00:00
Commit Graph

1949 Commits

Author SHA1 Message Date
Matt Borland
f7e3fc17a6 Additional t-tests (#487)
* Add integer support to t_test

* Add paired samples t test

* Add two sample t test

* Add welch's t test

* Update docs

* Cleanup

* Add CHECK_ULP_CLOSE tests to test battery. Fix svg

* Remove all instances of ex [CI SKIP]

* Remove std::distance and note in docs [CI SKIP]

* Re-write test battery
2021-01-12 15:48:53 -05:00
Nick
3b9f5adccc Increase tolerable ULPs in linear regression. 2021-01-11 13:24:25 -05:00
Matt Borland
f8e35601b0 Add integer support to t_test (#485) 2021-01-10 11:35:51 -05:00
Matt Borland
579d89c163 Add integer support to linear regression (#484)
* Add integer support to linear regression

* Fix for MSVC error C2668: 'fpclassify' [CI SKIP]

* Fix naming [CI SKIP]
2021-01-09 12:15:43 -05:00
Nick
5fc9214ad1 Update error rate in Cohen acceleration 2021-01-08 07:07:57 -06:00
Nick
163788bcbb Update error rate in cubic_hermite_test. (#482) 2021-01-08 07:06:06 -06:00
Matt Borland
fc7b75aceb Add integer support to bivariate statistics (#480)
* Add integer support to bivariate statistics
Reduce required CXXSTD from 17 to 11

* Fix failed test trying to use C++03 mode [CI SKIP]
2021-01-05 13:57:16 -05:00
jzmaddock
b0045c1f43 Merge pull request #463 from evanmiller/missing-braces
Add missing braces
2020-12-30 19:02:53 +00:00
jzmaddock
c845b0e82c Merge pull request #470 from mborland/issue464
Fix for issue #464
2020-12-30 19:01:55 +00:00
Matt Borland
a120962474 Fix parens [CI SKIP] 2020-12-30 16:29:52 +03:00
Matt Borland
cff9cfc1a3 Fix test file too... 2020-12-29 20:31:17 +03:00
Matt Borland
a13451838a Add test case of long long max + 1 2020-12-27 20:10:16 +03:00
Matt Borland
0c20005e1b Eliminate -Wimplicit-int-float-conversion on clang 2020-12-27 19:47:09 +03:00
jzmaddock
787481c6ff Merge pull request #433 from boostorg/issue396
Try fix min Bn arg for recur.
2020-12-24 18:35:46 +00:00
Matt Borland
9a4fbed2c1 Qualify constexpr-ness of std::real and std::imag 2020-12-24 09:57:04 +03:00
Evan Miller
0a17c5cb8a Add missing braces
Clang emits thousands of warnings when running test_gamma_mp due
to missing braces. Add them.
2020-12-22 12:16:53 -05:00
Matt Borland
a058883c71 Duplicated test case causing CI failure. 2020-12-20 22:13:07 +03:00
Matt Borland
118863da21 Change PDF to be 0 for x = 0 or x = 1 2020-12-20 16:01:05 +03:00
John Maddock
358eda5039 Merge branch 'develop' into issue396 2020-12-19 19:37:31 +00:00
jzmaddock
db42e6bced Add missing include.
Fixes issues exposed by changes to lexical_cast.
See https://github.com/boostorg/math/pull/433.
2020-12-19 19:31:01 +00:00
Christopher Kormanyos
8c7adc6856 [CI SKPI] Remove draft Jam unintended for tracking 2020-12-19 09:03:01 +01:00
Christopher Kormanyos
728388856c Guesses for old, running on new compilers, try CI 2020-12-16 18:50:06 +01:00
Christopher Kormanyos
92417f5a7f Work the review findings including no constexpr, use 3 spaces and eliminate use of size_t and will try CI again 2020-12-16 15:04:27 +01:00
Christopher Kormanyos
dd9015124d Reduce again complexity for old msvc 1001 2020-12-16 12:25:49 +01:00
Christopher Kormanyos
5f9c760321 Work around old msvc internal compiler error 2020-12-16 11:42:25 +01:00
Christopher Kormanyos
603a37534e Issue396 gets better tests and fix of Bn recur 2020-12-16 11:02:08 +01:00
Christopher Kormanyos
0db73891e5 i396 code now C++03 and bigobj MSVC and gcc-mingw 2020-12-14 20:30:38 +01:00
Christopher Kormanyos
1e61cea5df Improve fix, no pch, test spec fun locally 2020-12-14 07:21:52 +01:00
Christopher Kormanyos
90ee0013e7 Fix the fix of 396 and expand its test case 2020-12-13 20:33:25 +01:00
Christopher Kormanyos
b29157c7e1 Fixes #396 tests tgamma fix and original report 2020-12-13 15:00:40 +01:00
pulver
a0a97b768a Fix derivative of pow(x,y) when x=0 (#456)
* Fix pow(x,y) for variable x=0 and constant y #445

* Add pow0 test.

Co-authored-by: Matt Pulver <mpulver@unitytechgroup.com>
2020-11-16 11:52:28 -05:00
jzmaddock
6cbd225994 Merge pull request #454 from boostorg/issue453
Fix up legendre_p(n, n-1, x) as special case.
2020-11-11 19:20:57 +00:00
jzmaddock
c25cae2067 Correct testing mistake in test_legendre.hpp. 2020-11-09 12:44:50 +00:00
jzmaddock
889620031a Fix up legendre_p(n, n-1, x) as special case.
Add tests.
Fixes https://github.com/boostorg/math/issues/453.
2020-11-08 20:47:25 +00:00
jzmaddock
56c4c890d1 Fix spurious overflow in gamma_p/q calculation.
Add tests.
Fixes: https://github.com/boostorg/math/issues/451
2020-11-05 19:43:52 +00:00
jzmaddock
6b8c2691d3 Correct expected error rate - epsilon should be as a percentage for BOOST_CHECK_CLOSE. 2020-10-30 11:36:17 +00:00
jzmaddock
f59b67ee9c Fix some CI test failures. 2020-10-13 18:34:11 +01:00
Evan Miller
18ed616376 Kolmogorov-Smirnov distribution (#422)
* Kolmogorov-Smirnov distribution #421

Add a new distribution, kolmogorov_smirnov_distribution, which takes a
parameter that represents the number of observations used in a
Kolmogorov-Smirnov test. (The K-S test is a popular test for comparing
two CDFs, but the test statistic is not implemented here.)

This implementation includes Kolmogorov's original 1st order Taylor
expansion. There is a literature on the distribution's other
mathematical properties (higher order terms and exact version); this
literature is summarized in the main header file for anyone who may
want to expand the implementation later.

The CDF is implemented using a Jacobi theta function, and the PDF is a
hand-rolled derivative of that function. Quantiles plug the CDF and PDF
into a Newton-Raphson iteration. The mean and variance have nice
closed-form expressions, and the mode uses a dumb run-time maximizer.

This commit includes graphs, a ULP plotter for the PDF, and the usual
compilation and numerical tests. The test file is on the small side, but
it integrates the distribution from zero to infinity, and covers the
quantiles pretty well. As of now the numerical tests only verify
self-consistency (e.g. distribution moments and CDF-quantile relations),
so there's room to add some external checks.

* Implement skewness for K-S distribution [CI SKIP]

The third moment integrates nicely with the help of Apery's constant
(zeta_three). Verify the result via quadrature.

* Implement kurtosis for the K-S distribution

Verify the result via quadrature.
2020-09-04 08:48:51 -04:00
jzmaddock
526fc6eef4 Update test_jacobi_theta compiler requirements in Jamfile.v2. 2020-08-27 18:36:18 +01:00
jzmaddock
b1c03c841a Jamfile.v2: Tidy up mpfr/gmp use so tests pass on mingw64 2020-08-18 11:19:48 +01:00
Evan Miller
d7141cd353 Jacobi Theta functions (#394)
* Jacobi Theta functions

Implementations, tests, and ULP plotting programs are provided for the
four Jacobi Theta functions per #373. Twenty-four public C++ functions
are provided in all, covering various precision-preserving scenarios.

Documentation for collaborators is provided in the code comments. Proper
documentation for end users will be provided when the implementation and
APIs are finalized.

Some tests are failing; this implementation is meant to start a
conversation. The core dilemma faced by the author was that large values
of |q| resulted in slow convergence, and sometimes wildly inaccurate
results. Following the implementation note in DLMF 20.14, I added code
to switch over to the imaginary versions of the theta functions when |q|
> 0.85.  This restored accuracy such that all of the identity tests
passed for a loose-enough epsilon, but then lost precision to the point
that the Wolfram Alpha spot checks failed. It is the author's hope that
someone with floating-point experience can tame the exponential dragons
and squeeze the ULPs back down to a reasonable range when |q| is large.

When #392 is merged I will add more thorough value tests, although I
fully expect them to fail until the underlying precision issues are
resolved.

As a final note, the precision issues do not affect the z=0 case - the
ULP plots indicate these return values within 2 ULP across all valid
|q|. So that's a start.

* [CI SKIP] Jacobi theta: Add special-value tests and more

* Add tests covering z=0 special values from MathWorld

* Add missing real_concept header

* Replace M_PI and friends with constants::pi etc

* Use BOOST_MATH_STD_USING in more places

* Jacobi theta: Test two more of Watson's identities [CI SKIP]

See https://mathworld.wolfram.com/JacobiThetaFunctions.html

(Equations 48 and 49)

* Improve precision of Jacobi theta functions [CI SKIP]

Rewrite the private imaginary versions to use double-sided summations
following DLMF 20.13.4 and 20.13.5. This cuts down the worst of the
precision issues by a factor of 10, and gets more of the tests to pass.

I am confident enough in the code path to eliminate the compile-time
__JACOBI_THETA_USE_IMAGINARY flag. In fact the imaginary-z code paths
are now enabled for all |q| > 0.04, i.e. most legal values of q.

More extensive tests will be needed to illuminate any remaining
precision issues.

* Jacobi theta: Make changes suggested in #394 [CI SKIP]

* Add LICENSE notice to main file

* Document convergence criteria

* Eliminate eps*eps = 0 logic. This causes some disagreement with the
zero returned by Wolfram Alpha for z=0, q > 0.99 in the fourth function.
Mathematically, the fourth function is never exactly zero, so I don't
trust Wolfram here.

* Per code-review comments, remove multiplications by floating-point 2.

* Tweak the plotting programs to display their titles, and to uniformly
use `float` as their CoarseType and `long double` as their
`PreciseType`.

* Add quadrature tests to Jacobi theta functions [CI SKIP]

The quadrature tests revealed a problem in the m1 functions: they too
should switch to the _IMAGINARY logic for q > exp(-pi), or will suffer
from slow convergence. Fix them.

Also tighten tolerances for many tests from sqrt(eps) to 100 * eps.

* Test Jacobi thetas against elliptic functions and elliptic integrals [CI SKIP]

See:

* https://dlmf.nist.gov/22.2
* https://dlmf.nist.gov/20.9#i

* Test Jacobi Thetas against their Laplace transforms [CI SKIP]

See:

* https://dlmf.nist.gov/20.10#ii

I did find some disagreement, and dropped the negative sign from the
theta1 equation. DLMF's theta2 and theta3 Laplace transform equations do
not agree at all with the computed values - will need to investigate.

In the meantime, the two implemented equations agree to 4 EPS so I am
keeping them.

* Add a note on using log1p with Jacobi theta functions [CI SKIP]

See discussion:

* https://github.com/boostorg/math/pull/394#issuecomment-655871762

* Add random data tests to Jacobi Theta functions [CI SKIP]

Add a test data generator program for the Jacobi theta functions.
This program will produce data for the tau parameterization, so that
precision isn't lost during the log-transformation. This distinguishes
it from the Wolfram Alpha data, which is parameterized by q.

A few of these new random-data tests are failing, but not by obscene
margins (< 100 EPS). These failures will be addressed when the test
tolerances are finalized.

* Add small-tau tests and simplify Jacobi Theta code [CI SKIP]

Add tests for small tau (i.e. large q). The tests are failing with mean
~ 200 EPS and max ~ 800 EPS. These look like worst-case input, and
should be the focus of future accuracy improvements.

This commit also simplifies the _IMAGINARY code by abstracting all of
the loops into a single svelte function.

* Add user documentation for Jacobi Theta functions [CI SKIP]

* Add function graphs to Jacobi Theta docs [CI SKIP]

* Define Jacobi Theta test tolerances [CI SKIP]

* Add implementation note on Jacobi theta functions [CI SKIP]

* Consolidate Jacobi Theta ULPs plotting programs [CI SKIP]

* Fix q domain checking of jacobi_theta4 [CI SKIP]

* Add ULPs plots to Jacobi Theta docs [CI SKIP]

Also add the built HTML files for easy evaluation. A full rebuild is
needed for the new docs to appear in the indexes.

* Add missing Jacobi Theta ULPs plots [CI SKIP]

* Add LaTeX source for Jacobi Theta equations [CI SKIP]

* Remove unused Jacobi Theta PNG equations [CI SKIP]

* Add Jacobi Theta performance script [CI SKIP]

Provided by @NAThompson.

* Remove vestigial eps*eps check from jacobi_theta3 [CI SKIP]

* Update Jacobi Theta docs per code review comments [CI SKIP]

* Enable arg promotion for Jacobi Theta functions [CI SKIP]

Add Jacobi theta functions to the instantiation tests and fix up
everything needed to make them pass. This changes the function
signatures to use promote_args.

* Fix Jacobi Theta plotting script [CI SKIP]

This script broke when the promote_args API was added.

* Change Jacobi Theta convergence criterion [CI SKIP]

Compare the non-oscillating part of the delta to the previous one.
This avoids some headaches comparing the delta to the partial sum,
because the partial sum can be a small number due to the oscillating
component alternating signs.

Because successive terms involve either q^n^2 or exp(-(pi*n)^2),
convergence should still happen pretty quickly. Graphs have been updated
and tests still passs with no noticeable difference.
2020-08-15 18:51:47 -04:00
Nick
cbd2af2890 Cohen acceleration (#415)
* Cohen acceleration

Accelerates convergence of an alternating series by a method designed by Cohen, Villegas, and Zagier.
2020-08-09 09:55:56 -04:00
John Maddock
01f495015c Merge branch 'no_long_double_fixes' into develop 2020-07-31 18:14:09 +01:00
jzmaddock
801eff2504 Correct test case for C++03, add missing copyright. 2020-07-28 08:39:16 +01:00
Nick
fa23c83bb1 Laplace limit. (#409) 2020-07-27 21:26:24 -04:00
jzmaddock
c4972b0214 Merge pull request #408 from boostorg/issue406
Fix bug in student's T quantile for denormalized degrees_of_freedom.
2020-07-27 19:34:54 +01:00
jzmaddock
a316c72bb6 Correct lgamma workaround for very small arguments.
This allows simplification of the student's T quantile code.
Added some more lgamma tests.
2020-07-25 18:30:03 +01:00
Nick
326faa4c28 Reciprocal Fibonacci constant and Dottie number. (#407) 2020-07-25 09:26:38 -04:00
jzmaddock
fa8f763df9 Fix bug in student's T quantile for denormalized degrees_of_freedom. 2020-07-24 20:11:48 +01:00
Nick
8792935679 Engel expansions (#404) 2020-07-20 09:51:17 -04:00