mirror of
https://github.com/boostorg/math.git
synced 2026-01-19 04:22:09 +00:00
Fix many, many obvious test bugs (#1212)
Needed for tests to pass with 128 bit long double types Co-authored-by: Reimar Döffinger <reimar.doeffinger@arm.com>
This commit is contained in:
@@ -76,9 +76,7 @@ int main()
|
|||||||
|
|
||||||
// Types that are convertible to int
|
// Types that are convertible to int
|
||||||
test<short>();
|
test<short>();
|
||||||
#if CHAR_MIN != 0
|
test<signed char>();
|
||||||
test<char>();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// fabs
|
// fabs
|
||||||
fabs_test<float>();
|
fabs_test<float>();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
|
#include <cstdint>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <boost/math/ccmath/isinf.hpp>
|
#include <boost/math/ccmath/isinf.hpp>
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <cstdint>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <boost/math/ccmath/sqrt.hpp>
|
#include <boost/math/ccmath/sqrt.hpp>
|
||||||
|
|||||||
@@ -297,8 +297,8 @@ void test_first_derivative()
|
|||||||
// Limited precision test data means we can't test long double here...
|
// Limited precision test data means we can't test long double here...
|
||||||
#else
|
#else
|
||||||
auto phi1_3 = boost::math::detail::daubechies_scaling_integer_grid<long double, 3, 1>();
|
auto phi1_3 = boost::math::detail::daubechies_scaling_integer_grid<long double, 3, 1>();
|
||||||
std::array<long double, 6> lin_3{0.0L, 1.638452340884085725014976L, -2.232758190463137395017742L,
|
std::array<long double, 6> lin_3{0.0L, 1.638452340884085725014976113635604107L, -2.23275819046313739501774225255380757L,
|
||||||
0.5501593582740176149905562L, 0.04414649130503405501220997L, 0.0L};
|
0.550159358274017614990556164200803310L, 0.044146491305034055012209974717400368L, 0.0L};
|
||||||
for (size_t i = 0; i < lin_3.size(); ++i)
|
for (size_t i = 0; i < lin_3.size(); ++i)
|
||||||
{
|
{
|
||||||
if(!CHECK_ULP_CLOSE(lin_3[i], phi1_3[i], 0))
|
if(!CHECK_ULP_CLOSE(lin_3[i], phi1_3[i], 0))
|
||||||
@@ -308,8 +308,8 @@ void test_first_derivative()
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto phi1_4 = boost::math::detail::daubechies_scaling_integer_grid<long double, 4, 1>();
|
auto phi1_4 = boost::math::detail::daubechies_scaling_integer_grid<long double, 4, 1>();
|
||||||
std::array<long double, 8> lin_4 = {0.0L, 1.776072007522184640093776L, -2.785349397229543142492785L, 1.192452536632278174347632L,
|
std::array<long double, 8> lin_4 = {0.0L, 1.776072007522184640093776071522502761L, -2.785349397229543142492784905731245880L, 1.192452536632278174347632339082851360L,
|
||||||
-0.1313745151846729587935189L, -0.05357102822023923595359996L,0.001770396479992522798495351L, 0.0L};
|
-0.131374515184672958793518896272545740L, -0.053571028220239235953599959390993709L,0.001770396479992522798495350789431024L, 0.0L};
|
||||||
|
|
||||||
for (size_t i = 0; i < lin_4.size(); ++i)
|
for (size_t i = 0; i < lin_4.size(); ++i)
|
||||||
{
|
{
|
||||||
@@ -319,8 +319,8 @@ void test_first_derivative()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<long double, 10> lin_5 = {0.0L, 1.558326313047001366564379L, -2.436012783189551921436896L, 1.235905129801454293947039L, -0.3674377136938866359947561L,
|
std::array<long double, 10> lin_5 = {0.0L, 1.558326313047001366564379221011472479L, -2.436012783189551921436895932290077033L, 1.235905129801454293947038906779457610L, -0.367437713693886635994756136622838186L,
|
||||||
-0.02178035117564654658884556L,0.03234719350814368885815854L,-0.001335619912770701035229331L,-0.00001216838474354431384970525L,0.0L};
|
-0.021780351175646546588845564309594589L,0.032347193508143688858158541500450925L,-0.001335619912770701035229330817898250L,-0.000012168384743544313849705250972915L,0.0L};
|
||||||
auto phi1_5 = boost::math::detail::daubechies_scaling_integer_grid<long double, 5, 1>();
|
auto phi1_5 = boost::math::detail::daubechies_scaling_integer_grid<long double, 5, 1>();
|
||||||
for (size_t i = 0; i < lin_5.size(); ++i)
|
for (size_t i = 0; i < lin_5.size(); ++i)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ void test_airy(T, const char* name)
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
T tol = boost::math::tools::epsilon<T>() * 800;
|
T tol = boost::math::tools::epsilon<T>() * 800;
|
||||||
if ((std::numeric_limits<T>::digits > 100) || (std::numeric_limits<T>::digits == 0))
|
if (boost::math::tools::digits<T>() > 100)
|
||||||
tol *= 2;
|
tol *= 2;
|
||||||
|
|
||||||
#ifdef SYCL_LANGUAGE_VERSION
|
#ifdef SYCL_LANGUAGE_VERSION
|
||||||
|
|||||||
@@ -522,6 +522,17 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(asinh_test, T, bin_float_types) {
|
|||||||
-39 / (16 * boost::math::constants::root_two<T>()), eps);
|
-39 / (16 * boost::math::constants::root_two<T>()), eps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
static T atan2_wrap(T x, T y)
|
||||||
|
{
|
||||||
|
return atan2(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static long double atan2_wrap(long double x, long double y)
|
||||||
|
{
|
||||||
|
return std::atan2(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE_TEMPLATE(atan2_function, T, all_float_types) {
|
BOOST_AUTO_TEST_CASE_TEMPLATE(atan2_function, T, all_float_types) {
|
||||||
using test_constants = test_constants_t<T>;
|
using test_constants = test_constants_t<T>;
|
||||||
using std::atan2;
|
using std::atan2;
|
||||||
@@ -536,7 +547,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(atan2_function, T, all_float_types) {
|
|||||||
auto y = y_sampler.next();
|
auto y = y_sampler.next();
|
||||||
|
|
||||||
auto autodiff_v = atan2(make_fvar<T, m>(x), make_fvar<T, m>(y));
|
auto autodiff_v = atan2(make_fvar<T, m>(x), make_fvar<T, m>(y));
|
||||||
auto anchor_v = atan2(x, y);
|
auto anchor_v = atan2_wrap(x, y);
|
||||||
BOOST_CHECK_CLOSE(autodiff_v, anchor_v,
|
BOOST_CHECK_CLOSE(autodiff_v, anchor_v,
|
||||||
5000 * test_constants::pct_epsilon());
|
5000 * test_constants::pct_epsilon());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ void test_spots(T)
|
|||||||
BOOST_CHECK_CLOSE(::boost::math::beta(small, static_cast<T>(4)), 1/small, tolerance);
|
BOOST_CHECK_CLOSE(::boost::math::beta(small, static_cast<T>(4)), 1/small, tolerance);
|
||||||
BOOST_CHECK_CLOSE(::boost::math::beta(small, small / 2), boost::math::tgamma(small) * boost::math::tgamma(small / 2) / boost::math::tgamma(small + small / 2), tolerance);
|
BOOST_CHECK_CLOSE(::boost::math::beta(small, small / 2), boost::math::tgamma(small) * boost::math::tgamma(small / 2) / boost::math::tgamma(small + small / 2), tolerance);
|
||||||
BOOST_CHECK_CLOSE(::boost::math::beta(static_cast<T>(4), static_cast<T>(20)), static_cast<T>(0.00002823263692828910220214568040654997176736L), tolerance);
|
BOOST_CHECK_CLOSE(::boost::math::beta(static_cast<T>(4), static_cast<T>(20)), static_cast<T>(0.00002823263692828910220214568040654997176736L), tolerance);
|
||||||
if ((std::numeric_limits<T>::digits < 100) && (std::numeric_limits<T>::digits != 0))
|
if (boost::math::tools::digits<T>() < 100)
|
||||||
{
|
{
|
||||||
// Inexact input, so disable for ultra precise long doubles:
|
// Inexact input, so disable for ultra precise long doubles:
|
||||||
BOOST_CHECK_CLOSE(::boost::math::beta(static_cast<T>(0.0125L), static_cast<T>(0.000023L)), static_cast<T>(43558.24045647538375006349016083320744662L), tolerance * 2);
|
BOOST_CHECK_CLOSE(::boost::math::beta(static_cast<T>(0.0125L), static_cast<T>(0.000023L)), static_cast<T>(43558.24045647538375006349016083320744662L), tolerance * 2);
|
||||||
|
|||||||
@@ -384,10 +384,10 @@ T generate_random()
|
|||||||
val += gen();
|
val += gen();
|
||||||
}
|
}
|
||||||
e_type e;
|
e_type e;
|
||||||
val = frexp(val, &e);
|
val = std::frexp(val, &e);
|
||||||
|
|
||||||
static boost::random::uniform_int_distribution<e_type> ui(0, std::numeric_limits<T>::max_exponent - 10);
|
static boost::random::uniform_int_distribution<e_type> ui(0, std::numeric_limits<T>::max_exponent - 10);
|
||||||
return ldexp(val, ui(gen));
|
return std::ldexp(val, ui(gen));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
|||||||
@@ -41,30 +41,28 @@ void test_spots(RealType)
|
|||||||
using ::boost::math::normal_distribution;
|
using ::boost::math::normal_distribution;
|
||||||
BOOST_MATH_STD_USING // ADL of std names.
|
BOOST_MATH_STD_USING // ADL of std names.
|
||||||
|
|
||||||
if(std::numeric_limits<RealType>::digits && (std::numeric_limits<RealType>::digits < 100))
|
// Checks of six sub-methods T1 to T6.
|
||||||
{
|
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(0.0625L), static_cast<RealType>(0.25L)), static_cast<RealType>(3.89119302347013668966224771378499505568e-2L), tolerance); // T1
|
||||||
|
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(6.5L), static_cast<RealType>(0.4375L)), static_cast<RealType>(2.00057730485083154100907167684918851101649922551817956120806662022118025e-11L), tolerance); // T2
|
||||||
|
if (boost::math::tools::digits<RealType>() < 100) // too large error for 128 bit long double
|
||||||
|
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(7L), static_cast<RealType>(0.96875L)), static_cast<RealType>(6.3990627193898685308321991442891601376479719094145923322318222572484602e-13L), tolerance); // T3
|
||||||
|
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(4.78125L), static_cast<RealType>(0.0625L)), static_cast<RealType>(1.06329748046874638058307112826015825291136503488102191050906959246644943e-7L), tolerance); // T4
|
||||||
|
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(2.L), static_cast<RealType>(0.5L)), static_cast<RealType>(8.6250779855215071311348831915463718787564119039085429110080944948781288e-3L), tolerance); // T5
|
||||||
|
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(1.L), static_cast<RealType>(0.9999975L)), static_cast<RealType>(6.6741808978228592771558982240461689232406934240709035854119334966793020e-2L), tolerance); // T6
|
||||||
|
//BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(L), static_cast<RealType>(L)), static_cast<RealType>(L), tolerance);
|
||||||
|
|
||||||
// Checks of six sub-methods T1 to T6.
|
// BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(L), static_cast<RealType>(L)), static_cast<RealType>(L), tolerance);
|
||||||
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(0.0625L), static_cast<RealType>(0.25L)), static_cast<RealType>(3.89119302347013668966224771378e-2L), tolerance); // T1
|
|
||||||
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(6.5L), static_cast<RealType>(0.4375L)), static_cast<RealType>(2.00057730485083154100907167685E-11L), tolerance); // T2
|
|
||||||
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(7L), static_cast<RealType>(0.96875L)), static_cast<RealType>(6.39906271938986853083219914429E-13L), tolerance); // T3
|
|
||||||
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(4.78125L), static_cast<RealType>(0.0625L)), static_cast<RealType>(1.06329748046874638058307112826E-7L), tolerance); // T4
|
|
||||||
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(2.L), static_cast<RealType>(0.5L)), static_cast<RealType>(8.62507798552150713113488319155E-3L), tolerance); // T5
|
|
||||||
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(1.L), static_cast<RealType>(0.9999975L)), static_cast<RealType>(6.67418089782285927715589822405E-2L), tolerance); // T6
|
|
||||||
//BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(L), static_cast<RealType>(L)), static_cast<RealType>(L), tolerance);
|
|
||||||
|
|
||||||
// BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(L), static_cast<RealType>(L)), static_cast<RealType>(L), tolerance);
|
// Spots values using Mathematica
|
||||||
|
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(6.5L), static_cast<RealType>(0.4375L)), static_cast<RealType>(2.00057730485083154100907167684918851101649922551817956120806662022118024594547E-11L), tolerance);
|
||||||
// Spots values using Mathematica
|
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(0.4375L), static_cast<RealType>(6.5L)), static_cast<RealType>(0.16540130125449396247498691826626273249659241838438244251206819782787761751256L), tolerance);
|
||||||
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(6.5L), static_cast<RealType>(0.4375L)), static_cast<RealType>(2.00057730485083154100907167684918851101649922551817956120806662022118024594547E-11L), tolerance);
|
if (boost::math::tools::digits<RealType>() < 100) // too large error for 128 bit long double
|
||||||
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(0.4375L), static_cast<RealType>(6.5L)), static_cast<RealType>(0.16540130125449396247498691826626273249659241838438244251206819782787761751256L), tolerance);
|
|
||||||
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(7.L), static_cast<RealType>(0.96875L)), static_cast<RealType>(6.39906271938986853083219914428916013764797190941459233223182225724846022843930e-13L), tolerance);
|
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(7.L), static_cast<RealType>(0.96875L)), static_cast<RealType>(6.39906271938986853083219914428916013764797190941459233223182225724846022843930e-13L), tolerance);
|
||||||
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(0.96875L), static_cast<RealType>(7.L)), static_cast<RealType>(0.08316748474602973770533230453272140919966614259525787470390475393923633179072L), tolerance);
|
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(0.96875L), static_cast<RealType>(7.L)), static_cast<RealType>(0.08316748474602973770533230453272140919966614259525787470390475393923633179072L), tolerance);
|
||||||
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(4.78125L), static_cast<RealType>(0.0625L)), static_cast<RealType>(1.06329748046874638058307112826015825291136503488102191050906959246644942646701e-7L), tolerance);
|
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(4.78125L), static_cast<RealType>(0.0625L)), static_cast<RealType>(1.06329748046874638058307112826015825291136503488102191050906959246644942646701e-7L), tolerance);
|
||||||
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(0.0625L), static_cast<RealType>(4.78125L)), static_cast<RealType>(0.21571185819897989857261253680409017017649352928888660746045361855686569265171L), tolerance);
|
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(0.0625L), static_cast<RealType>(4.78125L)), static_cast<RealType>(0.21571185819897989857261253680409017017649352928888660746045361855686569265171L), tolerance);
|
||||||
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(2.L), static_cast<RealType>(0.5L)), static_cast<RealType>(0.00862507798552150713113488319154637187875641190390854291100809449487812876461L), tolerance);
|
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(2.L), static_cast<RealType>(0.5L)), static_cast<RealType>(0.00862507798552150713113488319154637187875641190390854291100809449487812876461L), tolerance);
|
||||||
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(0.5L), static_cast<RealType>(2L)), static_cast<RealType>(0.14158060365397839346662819588111542648867283386549027383784843786494855594607L), tolerance);
|
BOOST_CHECK_CLOSE_FRACTION(owens_t(static_cast<RealType>(0.5L), static_cast<RealType>(2L)), static_cast<RealType>(0.14158060365397839346662819588111542648867283386549027383784843786494855594607L), tolerance);
|
||||||
}
|
|
||||||
// check basic properties
|
// check basic properties
|
||||||
BOOST_CHECK_EQUAL(owens_t(static_cast<RealType>(0.5L), static_cast<RealType>(2L)), owens_t(static_cast<RealType>(-0.5L), static_cast<RealType>(2L)));
|
BOOST_CHECK_EQUAL(owens_t(static_cast<RealType>(0.5L), static_cast<RealType>(2L)), owens_t(static_cast<RealType>(-0.5L), static_cast<RealType>(2L)));
|
||||||
BOOST_CHECK_EQUAL(owens_t(static_cast<RealType>(0.5L), static_cast<RealType>(2L)), -owens_t(static_cast<RealType>(0.5L), static_cast<RealType>(-2L)));
|
BOOST_CHECK_EQUAL(owens_t(static_cast<RealType>(0.5L), static_cast<RealType>(2L)), -owens_t(static_cast<RealType>(0.5L), static_cast<RealType>(-2L)));
|
||||||
|
|||||||
@@ -356,7 +356,7 @@ void test_spots(RealType)
|
|||||||
|
|
||||||
BOOST_CHECK_CLOSE( // mean:
|
BOOST_CHECK_CLOSE( // mean:
|
||||||
mean(dist)
|
mean(dist)
|
||||||
, static_cast<RealType>(-0.579908992539856825862549L), tol10 * 2);
|
, static_cast<RealType>(-0.5799089925398568258625490172876619L), tol10 * 2);
|
||||||
|
|
||||||
std::cout << std::setprecision(17) << "Variance = " << variance(dist) << std::endl;
|
std::cout << std::setprecision(17) << "Variance = " << variance(dist) << std::endl;
|
||||||
BOOST_CHECK_CLOSE( // variance: N[variance[skewnormaldistribution[1.1, 2.2, -3.3]], 50]
|
BOOST_CHECK_CLOSE( // variance: N[variance[skewnormaldistribution[1.1, 2.2, -3.3]], 50]
|
||||||
@@ -365,27 +365,27 @@ void test_spots(RealType)
|
|||||||
|
|
||||||
BOOST_CHECK_CLOSE( // skewness:
|
BOOST_CHECK_CLOSE( // skewness:
|
||||||
skewness(dist)
|
skewness(dist)
|
||||||
, static_cast<RealType>(-0.709854548171537509192897824663L), tol100);
|
, static_cast<RealType>(-0.709854548171537509192897824663027155L), tol100);
|
||||||
BOOST_CHECK_CLOSE( // kurtosis:
|
BOOST_CHECK_CLOSE( // kurtosis:
|
||||||
kurtosis(dist)
|
kurtosis(dist)
|
||||||
, static_cast<RealType>(3.5538752625241790601377L), tol100);
|
, static_cast<RealType>(3.55387526252417906013770535120683805L), tol100);
|
||||||
BOOST_CHECK_CLOSE( // kurtosis excess:
|
BOOST_CHECK_CLOSE( // kurtosis excess:
|
||||||
kurtosis_excess(dist)
|
kurtosis_excess(dist)
|
||||||
, static_cast<RealType>(0.5538752625241790601377L), tol100);
|
, static_cast<RealType>(0.553875262524179060137705351206838143L), tol100);
|
||||||
|
|
||||||
BOOST_CHECK_CLOSE(
|
BOOST_CHECK_CLOSE(
|
||||||
pdf(dist, static_cast<RealType>(0.4L)),
|
pdf(dist, static_cast<RealType>(0.4L)),
|
||||||
static_cast<RealType>(0.294140110156599539564571L),
|
static_cast<RealType>(0.294140110156599539564571034730246656L),
|
||||||
tol10);
|
tol10);
|
||||||
|
|
||||||
BOOST_CHECK_CLOSE(
|
BOOST_CHECK_CLOSE(
|
||||||
cdf(dist, static_cast<RealType>(0.4L)),
|
cdf(dist, static_cast<RealType>(0.4L)),
|
||||||
static_cast<RealType>(0.7339186189278737976326676452L),
|
static_cast<RealType>(0.733918618927873797632667645226588243L),
|
||||||
tol100);
|
tol100);
|
||||||
|
|
||||||
BOOST_CHECK_CLOSE(
|
BOOST_CHECK_CLOSE(
|
||||||
quantile(dist, static_cast<RealType>(0.3L)),
|
quantile(dist, static_cast<RealType>(0.3L)),
|
||||||
static_cast<RealType>(-1.180104068086875314419247L),
|
static_cast<RealType>(-1.18010406808687531441924729956233392L),
|
||||||
tol100);
|
tol100);
|
||||||
|
|
||||||
|
|
||||||
@@ -395,72 +395,63 @@ void test_spots(RealType)
|
|||||||
|
|
||||||
// cout << "pdf(dist, 0) = " << pdf(dist, 0) << ", pdf(dist, 0.45) = " << pdf(dist, 0.45) << endl;
|
// cout << "pdf(dist, 0) = " << pdf(dist, 0) << ", pdf(dist, 0.45) = " << pdf(dist, 0.45) << endl;
|
||||||
// BOOST_CHECK_CLOSE(mode(dist), boost::math::constants::root_two<RealType>() / 2, tol5);
|
// BOOST_CHECK_CLOSE(mode(dist), boost::math::constants::root_two<RealType>() / 2, tol5);
|
||||||
BOOST_CHECK_CLOSE(mode(dist), static_cast<RealType>(0.41697299497388863932L), tol100);
|
BOOST_CHECK_CLOSE(mode(dist), static_cast<RealType>(0.416972994973888639318345129445233074L), tol100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if(std::numeric_limits< RealType>::digits && (std::numeric_limits<RealType>::digits < 100))
|
dist = skew_normal_distribution<RealType>(static_cast<RealType>(1.1l), static_cast<RealType>(0.02l), static_cast<RealType>(0.03l));
|
||||||
{
|
|
||||||
dist = skew_normal_distribution<RealType>(static_cast<RealType>(1.1l), static_cast<RealType>(0.02l), static_cast<RealType>(0.03l));
|
|
||||||
|
|
||||||
BOOST_CHECK_CLOSE( // mean:
|
BOOST_CHECK_CLOSE( // mean:
|
||||||
mean(dist)
|
mean(dist)
|
||||||
, static_cast<RealType>(1.1004785154529557886162L), tol10);
|
, static_cast<RealType>(1.1004785154529557886162056250600829L), tol10);
|
||||||
BOOST_CHECK_CLOSE( // variance:
|
BOOST_CHECK_CLOSE( // variance:
|
||||||
variance(dist)
|
variance(dist)
|
||||||
, static_cast<RealType>(0.00039977102296128251645L), tol10);
|
, static_cast<RealType>(0.000399771022961282516451686289719995601L), tol10);
|
||||||
|
|
||||||
BOOST_CHECK_CLOSE( // skewness:
|
BOOST_CHECK_CLOSE( // skewness:
|
||||||
skewness(dist)
|
skewness(dist)
|
||||||
, static_cast<RealType>(5.8834811259890359782e-006L), tol100);
|
, static_cast<RealType>(5.88348112598903597820852388986073439e-006L), tol100);
|
||||||
BOOST_CHECK_CLOSE( // kurtosis:
|
BOOST_CHECK_CLOSE( // kurtosis:
|
||||||
kurtosis(dist)
|
kurtosis(dist)
|
||||||
, static_cast<RealType>(3.L + 9.2903475812137800239002e-008L), tol100);
|
, static_cast<RealType>(3.L + 9.290347581213780023900209941e-008L), tol100);
|
||||||
BOOST_CHECK_CLOSE( // kurtosis excess:
|
BOOST_CHECK_CLOSE( // kurtosis excess:
|
||||||
kurtosis_excess(dist)
|
kurtosis_excess(dist)
|
||||||
, static_cast<RealType>(9.2903475812137800239002e-008L), tol100);
|
, static_cast<RealType>(9.29034758121378002390020993765449518e-008L), tol100);
|
||||||
}
|
dist = skew_normal_distribution<RealType>(static_cast<RealType>(10.1l), static_cast<RealType>(5.l), static_cast<RealType>(-0.03l));
|
||||||
if (std::numeric_limits< RealType>::digits && (std::numeric_limits<RealType>::digits < 100))
|
BOOST_CHECK_CLOSE( // mean:
|
||||||
{
|
|
||||||
dist = skew_normal_distribution<RealType>(static_cast<RealType>(10.1l), static_cast<RealType>(5.l), static_cast<RealType>(-0.03l));
|
|
||||||
BOOST_CHECK_CLOSE( // mean:
|
|
||||||
mean(dist)
|
mean(dist)
|
||||||
, static_cast<RealType>(9.9803711367610528459485937L), tol10);
|
, static_cast<RealType>(9.98037113676105284594859373497928476L), tol10);
|
||||||
BOOST_CHECK_CLOSE( // variance:
|
BOOST_CHECK_CLOSE( // variance:
|
||||||
variance(dist)
|
variance(dist)
|
||||||
, static_cast<RealType>(24.98568893508015727823L), tol10);
|
, static_cast<RealType>(24.9856889350801572782303931074997234L), tol10);
|
||||||
|
|
||||||
BOOST_CHECK_CLOSE( // skewness:
|
BOOST_CHECK_CLOSE( // skewness:
|
||||||
skewness(dist)
|
skewness(dist)
|
||||||
, static_cast<RealType>(-5.8834811259890359782085e-006L), tol100);
|
, static_cast<RealType>(-5.88348112598903597820852388986073439e-006L), tol100);
|
||||||
BOOST_CHECK_CLOSE( // kurtosis:
|
BOOST_CHECK_CLOSE( // kurtosis:
|
||||||
kurtosis(dist)
|
kurtosis(dist)
|
||||||
, static_cast<RealType>(3.L + 9.2903475812137800239002e-008L), tol100);
|
, static_cast<RealType>(3.L + 9.290347581213780023900209941e-008L), tol100);
|
||||||
BOOST_CHECK_CLOSE( // kurtosis excess:
|
BOOST_CHECK_CLOSE( // kurtosis excess:
|
||||||
kurtosis_excess(dist)
|
kurtosis_excess(dist)
|
||||||
, static_cast<RealType>(9.2903475812137800239002e-008L), tol100);
|
, static_cast<RealType>(9.29034758121378002390020993765449518e-008L), tol100);
|
||||||
}
|
dist = skew_normal_distribution<RealType>(static_cast<RealType>(-10.1l), static_cast<RealType>(5.l), static_cast<RealType>(30.l));
|
||||||
if (std::numeric_limits< RealType>::digits && (std::numeric_limits<RealType>::digits < 100))
|
BOOST_CHECK_CLOSE( // mean:
|
||||||
{
|
|
||||||
dist = skew_normal_distribution<RealType>(static_cast<RealType>(-10.1l), static_cast<RealType>(5.l), static_cast<RealType>(30.l));
|
|
||||||
BOOST_CHECK_CLOSE( // mean:
|
|
||||||
mean(dist)
|
mean(dist)
|
||||||
, static_cast<RealType>(-6.11279169674138408531365L), 2 * tol10);
|
, static_cast<RealType>(-6.11279169674138408531365149047090859L), 2 * tol10);
|
||||||
BOOST_CHECK_CLOSE( // variance:
|
BOOST_CHECK_CLOSE( // variance:
|
||||||
variance(dist)
|
variance(dist)
|
||||||
, static_cast<RealType>(9.10216994642554914628242L), tol10 * 2);
|
, static_cast<RealType>(9.10216994642554914628242097277880642L), tol10 * 2);
|
||||||
|
|
||||||
BOOST_CHECK_CLOSE( // skewness:
|
BOOST_CHECK_CLOSE( // skewness:
|
||||||
skewness(dist)
|
skewness(dist)
|
||||||
, static_cast<RealType>(0.99072425443686904424L), tol100);
|
, static_cast<RealType>(0.990724254436869044244695246354219556L), tol100);
|
||||||
BOOST_CHECK_CLOSE( // kurtosis:
|
BOOST_CHECK_CLOSE( // kurtosis:
|
||||||
kurtosis(dist)
|
kurtosis(dist)
|
||||||
, static_cast<RealType>(3.L + 0.8638862008406084244563L), tol100);
|
, static_cast<RealType>(3.L + 0.8638862008406084244563090239530549L), tol100);
|
||||||
BOOST_CHECK_CLOSE( // kurtosis excess:
|
BOOST_CHECK_CLOSE( // kurtosis excess:
|
||||||
kurtosis_excess(dist)
|
kurtosis_excess(dist)
|
||||||
, static_cast<RealType>(0.8638862008406084244563L), tol100);
|
, static_cast<RealType>(0.863886200840608424456309023953054896L), tol100);
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_MATH_CHECK_THROW(cdf(skew_normal_distribution<RealType>(0, 0, 0), 0), std::domain_error);
|
BOOST_MATH_CHECK_THROW(cdf(skew_normal_distribution<RealType>(0, 0, 0), 0), std::domain_error);
|
||||||
BOOST_MATH_CHECK_THROW(cdf(skew_normal_distribution<RealType>(0, -1, 0), 0), std::domain_error);
|
BOOST_MATH_CHECK_THROW(cdf(skew_normal_distribution<RealType>(0, -1, 0), 0), std::domain_error);
|
||||||
|
|||||||
Reference in New Issue
Block a user