mirror of
https://github.com/boostorg/math.git
synced 2026-01-19 04:22:09 +00:00
Improve performance of non-central distributions and the logistic quantile.
Updated performance results. Fixed a few bugs in performance testing code. Added short-cut macros for new distributions in math.qbk. [SVN r50896]
This commit is contained in:
@@ -228,11 +228,15 @@ and use the function's name as the link text]
|
||||
[def __exp_distrib [link math_toolkit.dist.dist_ref.dists.exp_dist Exponential Distribution]]
|
||||
[def __F_distrib [link math_toolkit.dist.dist_ref.dists.f_dist Fisher F Distribution]]
|
||||
[def __gamma_distrib [link math_toolkit.dist.dist_ref.dists.gamma_dist Gamma Distribution]]
|
||||
[def __hypergeometric_distrib [link math_toolkit.dist.dist_ref.dists.hypergeometric_dist Hypergeometric Distribution]]
|
||||
[def __laplace_distrib [link math_toolkit.dist.dist_ref.dists.laplace_dist Laplace Distribution]]
|
||||
[def __logistic_distrib [link math_toolkit.dist.dist_ref.dists.logistic_dist Logistic Distribution]]
|
||||
[def __lognormal_distrib [link math_toolkit.dist.dist_ref.dists.lognormal_dist Log-normal Distribution]]
|
||||
[def __negative_binomial_distrib [link math_toolkit.dist.dist_ref.dists.negative_binomial_dist Negative Binomial Distribution]]
|
||||
[def __non_central_chi_squared_distrib [link math_toolkit.dist.dist_ref.dists.nc_chi_squared_dist Non Central Chi Squared]]
|
||||
[def __non_central_beta_distrib [link math_toolkit.dist.dist_ref.dists.nc_beta_dist noncentral beta distribution]]
|
||||
[def __non_central_F_distrib [link math_toolkit.dist.dist_ref.dists.nc_f_dist noncentral F distribution]]
|
||||
[def __non_central_t_distrib [link math_toolkit.dist.dist_ref.dists.nc_t_dist noncentral T distribution]]
|
||||
[def __normal_distrib [link math_toolkit.dist.dist_ref.dists.normal_dist Normal Distribution]]
|
||||
[def __poisson_distrib [link math_toolkit.dist.dist_ref.dists.poisson_dist Poisson Distribution]]
|
||||
[def __students_t_distrib [link math_toolkit.dist.dist_ref.dists.students_t_dist Students t Distribution]]
|
||||
|
||||
@@ -268,39 +268,53 @@ the `/Ox /arch:SSE2` options.
|
||||
|
||||
[heading Comparison to the R Statistical Library on Windows]
|
||||
|
||||
All the results were measured on a 2.8GHz Intel Pentium 4, 2Gb RAM, Windows XP
|
||||
machine, with the test program compiled with Microsoft Visual C++ 2005, and
|
||||
R-2.5.0 compiled in "standalone mode" with MinGW-3.4
|
||||
(R-2.5.0 appears not to be buildable with Visual C++).
|
||||
All the results were measured on a 2.0GHz Intel T5800 Core 2 Duo, 4Gb RAM, Windows Vista
|
||||
machine, with the test program compiled with Microsoft Visual C++ 2008, and
|
||||
R-2.8.1 compiled in "standalone mode" with MinGW-4.3
|
||||
(R-2.8.1 appears not to be buildable with Visual C++).
|
||||
|
||||
[table A Comparison to the R Statistical Library on Windows XP
|
||||
[[Statistical Function][Boost][R]]
|
||||
[[__beta_distrib CDF][[perf msvc-dist-beta-cdf..[para 1.20][para (1.916e-006s)]]][[perf msvc-dist-beta-R-cdf..[para *1.00*][para (1.597e-006s)]]]]
|
||||
[[__beta_distrib Quantile][[perf msvc-dist-beta-quantile..[para *1.00*][para (6.570e-006s)]]][[perf msvc-dist-beta-R-quantile..[para 74.66[footnote There are a small number of our test cases where the R library fails to converge on a result: these tend to dominate the performance result.]][para (4.905e-004s)]]]]
|
||||
[[__binomial_distrib CDF][[perf msvc-dist-binomial-cdf..[para *1.00*][para (5.276e-007s)]]][[perf msvc-dist-binom-R-cdf..[para 2.45][para (1.293e-006s)]]]]
|
||||
[[__binomial_distrib Quantile][[perf msvc-dist-binomial-quantile..[para *1.00*][para (4.013e-006s)]]][[perf msvc-dist-binom-R-quantile..[para 1.32][para (5.280e-006s)]]]]
|
||||
[[__cauchy_distrib CDF][[perf msvc-dist-cauchy-cdf..[para *1.00*][para (1.231e-007s)]]][[perf msvc-dist-cauchy-R-cdf..[para 1.28][para (1.576e-007s)]]]]
|
||||
[[__cauchy_distrib Quantile][[perf msvc-dist-cauchy-quantile..[para *1.00*][para (1.498e-007s)]]][[perf msvc-dist-cauchy-R-quantile..[para *1.00*][para (1.498e-007s)]]]]
|
||||
[[__chi_squared_distrib CDF][[perf msvc-dist-chi_squared-cdf..[para *1.00*][para (7.889e-007s)]]][[perf msvc-dist-chisq-R-cdf..[para 2.48][para (1.955e-006s)]]]]
|
||||
[[__chi_squared_distrib Quantile][[perf msvc-dist-chi_squared-quantile..[para *1.00*][para (4.303e-006s)]]][[perf msvc-dist-chisq-R-quantile..[para 1.61][para (6.925e-006s)]]]]
|
||||
[[__exp_distrib CDF][[perf msvc-dist-exponential-cdf..[para *1.00*][para (1.955e-007s)]]][[perf msvc-dist-exp-R-cdf..[para 1.97][para (3.844e-007s)]]]]
|
||||
[[__exp_distrib Quantile][[perf msvc-dist-exponential-quantile..[para 1.07][para (1.206e-007s)]]][[perf msvc-dist-exp-R-quantile..[para *1.00*][para (1.126e-007s)]]]]
|
||||
[[__F_distrib CDF][[perf msvc-dist-fisher_f-cdf..[para *1.00*][para (1.309e-006s)]]][[perf msvc-dist-f-R-cdf..[para 2.12][para (2.780e-006s)]]]]
|
||||
[[__F_distrib Quantile][[perf msvc-dist-fisher_f-quantile..[para *1.00*][para (7.204e-006s)]]][[perf msvc-dist-f-R-quantile..[para 1.78][para (1.280e-005s)]]]]
|
||||
[[__gamma_distrib CDF][[perf msvc-dist-gamma-cdf..[para *1.00*][para (1.076e-006s)]]][[perf msvc-dist-gamma-R-cdf..[para 2.07][para (2.227e-006s)]]]]
|
||||
[[__gamma_distrib Quantile][[perf msvc-dist-gamma-quantile..[para *1.00*][para (5.189e-006s)]]][[perf msvc-dist-gamma-R-quantile..[para 1.14][para (5.937e-006s)]]]]
|
||||
[[__lognormal_distrib CDF][[perf msvc-dist-lognormal-cdf..[para *1.00*][para (2.078e-007s)]]][[perf msvc-dist-lnorm-R-cdf..[para 1.41][para (2.930e-007s)]]]]
|
||||
[[__lognormal_distrib Quantile][[perf msvc-dist-lognormal-quantile..[para *1.00*][para (6.692e-007s)]]][[perf msvc-dist-lnorm-R-quantile..[para 1.63][para (1.090e-006s)]]]]
|
||||
[[__negative_binomial_distrib CDF][[perf msvc-dist-negative_binomial-cdf..[para *1.00*][para (9.005e-007s)]]][[perf msvc-dist-nbinom-R-cdf..[para 2.42][para (2.178e-006s)]]]]
|
||||
[[__negative_binomial_distrib Quantile][[perf msvc-dist-negative_binomial-quantile..[para *1.00*][para (9.601e-006s)]]][[perf msvc-dist-nbinom-R-quantile..[para 53.59[footnote The R library appears to use a linear-search strategy, that can perform very badly in a small number of pathological cases, but may or may not be more efficient in "typical" cases]][para (5.145e-004s)]]]]
|
||||
[[__normal_distrib CDF][[perf msvc-dist-normal-cdf..[para *1.00*][para (5.926e-008s)]]][[perf msvc-dist-norm-R-cdf..[para 3.01][para (1.785e-007s)]]]]
|
||||
[[__normal_distrib Quantile][[perf msvc-dist-normal-quantile..[para *1.00*][para (1.248e-007s)]]][[perf msvc-dist-norm-R-quantile..[para 1.05][para (1.311e-007s)]]]]
|
||||
[[__poisson_distrib CDF][[perf msvc-dist-poisson-cdf..[para *1.00*][para (8.999e-007s)]]][[perf msvc-dist-pois-R-cdf..[para 2.42][para (2.175e-006s)]]]]
|
||||
[[__poisson_distrib][[perf msvc-dist-poisson-quantile..[para *1.00*][para (1.853e-006s)]]][[perf msvc-dist-pois-R-quantile..[para 2.17][para (4.014e-006s)]]]]
|
||||
[[__students_t_distrib CDF][[perf msvc-dist-students_t-cdf..[para *1.00*][para (1.223e-006s)]]][[perf msvc-dist-t-R-cdf..[para 1.13][para (1.376e-006s)]]]]
|
||||
[[__students_t_distrib Quantile][[perf msvc-dist-students_t-quantile..[para *1.00*][para (2.570e-006s)]]][[perf msvc-dist-t-R-quantile..[para 1.04][para (2.668e-006s)]]]]
|
||||
[[__weibull_distrib CDF][[perf msvc-dist-weibull-cdf..[para *1.00*][para (4.741e-007s)]]][[perf msvc-dist-weibull-R-cdf..[para 1.46][para (6.943e-007s)]]]]
|
||||
[[__weibull_distrib Quantile][[perf msvc-dist-weibull-quantile..[para *1.00*][para (7.926e-007s)]]][[perf msvc-dist-weibull-R-quantile..[para 1.08][para (8.542e-007s)]]]]
|
||||
[[__beta_distrib CDF][[perf msvc-dist-beta-cdf..[para 1.32][para (1.683e-006s)]]][[perf msvc-dist-beta-R-cdf..[para *1.00*][para (1.271e-006s)]]]]
|
||||
[[__beta_distrib Quantile][[perf msvc-dist-beta-quantile..[para *1.00*][para (5.695e-006s)]]][[perf msvc-dist-beta-R-quantile..[para 58.77[footnote There are a small number of our test cases where the R library fails to converge on a result: these tend to dominate the performance result.]][para (3.347e-004s)]]]]
|
||||
[[__binomial_distrib CDF][[perf msvc-dist-binomial-cdf..[para *1.00*][para (5.276e-007s)]]][[perf msvc-dist-binom-R-cdf..[para 1.46][para (7.714e-007s)]]]]
|
||||
[[__binomial_distrib Quantile][[perf msvc-dist-binomial-quantile..[para *1.00*][para (3.608e-006s)]]][[perf msvc-dist-binom-R-quantile..[para 1.04][para (3.770e-006s)]]]]
|
||||
[[__cauchy_distrib CDF][[perf msvc-dist-cauchy-cdf..[para 1.53][para (1.878e-007s)]]][[perf msvc-dist-cauchy-R-cdf..[para *1.00*][para (1.229e-007s)]]]]
|
||||
[[__cauchy_distrib Quantile][[perf msvc-dist-cauchy-quantile..[para 1.65][para (1.997e-007s)]]][[perf msvc-dist-cauchy-R-quantile..[para *1.00*][para (1.213e-007s)]]]]
|
||||
[[__chi_squared_distrib CDF][[perf msvc-dist-chi_squared-cdf..[para *1.00*][para (6.258e-007s)]]][[perf msvc-dist-chisq-R-cdf..[para 1.91][para (1.196e-006s)]]]]
|
||||
[[__chi_squared_distrib Quantile][[perf msvc-dist-chi_squared-quantile..[para *1.00*][para (3.934e-006s)]]][[perf msvc-dist-chisq-R-quantile..[para 1.34][para (5.271e-006s)]]]]
|
||||
[[__exp_distrib CDF][[perf msvc-dist-exponential-cdf..[para *1.00*][para (1.017e-007s)]]][[perf msvc-dist-exp-R-cdf..[para 2.22][para (2.258e-007s)]]]]
|
||||
[[__exp_distrib Quantile][[perf msvc-dist-exponential-quantile..[para 1.69][para (1.079e-007s)]]][[perf msvc-dist-exp-R-quantile..[para *1.00*][para (6.398e-008s)]]]]
|
||||
[[__F_distrib CDF][[perf msvc-dist-fisher_f-cdf..[para *1.00*][para (1.114e-006s)]]][[perf msvc-dist-f-R-cdf..[para 1.16][para (1.296e-006s)]]]]
|
||||
[[__F_distrib Quantile][[perf msvc-dist-fisher_f-quantile..[para *1.00*][para (8.604e-006s)]]][[perf msvc-dist-f-R-quantile..[para 1.10][para (9.474e-006s)]]]]
|
||||
[[__gamma_distrib CDF][[perf msvc-dist-gamma-cdf..[para *1.00*][para (8.750e-007s)]]][[perf msvc-dist-gamma-R-cdf..[para 1.49][para (1.303e-006s)]]]]
|
||||
[[__gamma_distrib Quantile][[perf msvc-dist-gamma-quantile..[para *1.00*][para (4.449e-006s)]]][[perf msvc-dist-gamma-R-quantile..[para 2.49][para (1.110e-005s)]]]]
|
||||
|
||||
[[__hypergeometric_distrib CDF][[perf msvc-dist-hypergeometric-cdf..[para 1.55[footnote This result is somewhat misleading: for small values of the parameters there is virtually no difference between the two libraries, but for large values the Boost implementation is /much/ slower, albeit with much improved precision.]][para (2.583e-007s)]]][[perf msvc-dist-hypergeo-R-cdf..[para *1.00*][para (1.668e-007s)]]]]
|
||||
[[__hypergeometric_distrib Quantile][[perf msvc-dist-hypergeometric-quantile..[para *1.00*][para (2.369e-007s)]]][[perf msvc-dist-hypergeo-R-quantile..[para 8.46][para (2.004e-006s)]]]]
|
||||
[[__logistic_distrib CDF][[perf msvc-dist-logistic-cdf..[para *1.00*][para (1.550e-007s)]]][[perf msvc-dist-logis-R-cdf..[para 2.34][para (3.623e-007s)]]]]
|
||||
[[__logistic_distrib Quantile][[perf msvc-dist-logistic-quantile..[para 1.87][para (1.534e-007s)]]][[perf msvc-dist-logis-R-quantile..[para *1.00*][para (8.211e-008s)]]]]
|
||||
|
||||
[[__lognormal_distrib CDF][[perf msvc-dist-lognormal-cdf..[para 1.26][para (2.754e-007s)]]][[perf msvc-dist-lnorm-R-cdf..[para *1.00*][para (2.180e-007s)]]]]
|
||||
[[__lognormal_distrib Quantile][[perf msvc-dist-lognormal-quantile..[para *1.00*][para (4.811e-007s)]]][[perf msvc-dist-lnorm-R-quantile..[para 1.27][para (6.086e-007s)]]]]
|
||||
[[__negative_binomial_distrib CDF][[perf msvc-dist-negative_binomial-cdf..[para 1.36][para (1.903e-006s)]]][[perf msvc-dist-nbinom-R-cdf..[para *1.00*][para (1.398e-006s)]]]]
|
||||
[[__negative_binomial_distrib Quantile][[perf msvc-dist-negative_binomial-quantile..[para *1.00*][para (2.311e-005s)]]][[perf msvc-dist-nbinom-R-quantile..[para 16.03[footnote The R library appears to use a linear-search strategy, that can perform very badly in a small number of pathological cases, but may or may not be more efficient in "typical" cases]][para (3.704e-004s)]]]]
|
||||
|
||||
[[__non_central_chi_squared_distrib CDF][[perf msvc-dist-non_central_chi_squared-cdf..[para *1.00*][para (4.274e-006s)]]][[perf msvc-dist-nchisq-R-cdf..[para 34.09][para (1.457e-004s)]]]]
|
||||
[[__non_central_chi_squared_distrib Quantile][[perf msvc-dist-non_central_chi_squared-quantile..[para *1.00*][para (3.528e-004s)]]][[perf msvc-dist-nchisq-R-quantile..[para 75.71][para (2.671e-002s)]]]]
|
||||
[[__non_central_F_distrib CDF][[perf msvc-dist-non_central_f-cdf..[para *1.00*][para (1.182e-005s)]]][[perf msvc-dist-nf-R-cdf..[para 1.51][para (1.781e-005s)]]]]
|
||||
[[__non_central_F_distrib Quantile][[perf msvc-dist-non_central_f-quantile..[para *1.00*][para (4.822e-004s)]]][[perf msvc-dist-nf-R-quantile..[para 3.99][para (1.924e-003s)]]]]
|
||||
[[__non_central_t_distrib CDF][[perf msvc-dist-non_central_t-cdf..[para 3.58][para (1.937e-005s)]]][[perf msvc-dist-nt-R-cdf..[para *1.00*][para (5.411e-006s)]]]]
|
||||
[[__non_central_t_distrib Quantile][[perf msvc-dist-non_central_t-quantile..[para 1.34][para (5.933e-004s)]]][[perf msvc-dist-nt-R-quantile..[para *1.00*[footnote There are a small number of our test cases where the R library fails to converge on a result: these tend to dominate the performance result.]][para (4.432e-004s)]]]]
|
||||
|
||||
[[__normal_distrib CDF][[perf msvc-dist-normal-cdf..[para 1.22][para (1.667e-007s)]]][[perf msvc-dist-norm-R-cdf..[para *1.00*][para (1.372e-007s)]]]]
|
||||
[[__normal_distrib Quantile][[perf msvc-dist-normal-quantile..[para 1.97][para (2.323e-007s)]]][[perf msvc-dist-norm-R-quantile..[para *1.00*][para (1.182e-007s)]]]]
|
||||
[[__poisson_distrib CDF][[perf msvc-dist-poisson-cdf..[para *1.00*][para (6.680e-007s)]]][[perf msvc-dist-pois-R-cdf..[para 1.98][para (1.325e-006s)]]]]
|
||||
[[__poisson_distrib][[perf msvc-dist-poisson-quantile..[para *1.00*][para (1.532e-006s)]]][[perf msvc-dist-pois-R-quantile..[para 1.75][para (2.683e-006s)]]]]
|
||||
[[__students_t_distrib CDF][[perf msvc-dist-students_t-cdf..[para 1.08][para (1.002e-006s)]]][[perf msvc-dist-t-R-cdf..[para *1.00*][para (9.277e-007s)]]]]
|
||||
[[__students_t_distrib Quantile][[perf msvc-dist-students_t-quantile..[para *1.00*][para (2.444e-006s)]]][[perf msvc-dist-t-R-quantile..[para 1.29][para (3.159e-006s)]]]]
|
||||
[[__weibull_distrib CDF][[perf msvc-dist-weibull-cdf..[para 1.60][para (7.061e-007s)]]][[perf msvc-dist-weibull-R-cdf..[para *1.00*][para (4.404e-007s)]]]]
|
||||
[[__weibull_distrib Quantile][[perf msvc-dist-weibull-quantile..[para 1.02][para (1.133e-006s)]]][[perf msvc-dist-weibull-R-quantile..[para *1.00*][para (1.114e-006s)]]]]
|
||||
]
|
||||
|
||||
[heading Comparison to the R Statistical Library on Linux]
|
||||
@@ -367,3 +381,6 @@ __policy_section you want to test set as the default.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt).
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ namespace boost { namespace math {
|
||||
//return location - scale*log1p((1-2*p)/p);
|
||||
|
||||
//return -scale*log(1/p-1) + location;
|
||||
return location - scale * log1p((1 / p) - 2);
|
||||
return location - scale * log((1 - p) / p);
|
||||
} // RealType quantile(const logistic_distribution<RealType, Policy>& dist, const RealType& p)
|
||||
|
||||
template <class RealType, class Policy>
|
||||
@@ -228,7 +228,7 @@ namespace boost { namespace math {
|
||||
}
|
||||
//Expressions to try
|
||||
//return location+scale*log((1-q)/q);
|
||||
return location + scale * log1p((1 - 2 * q) / q);
|
||||
return location + scale * log((1 - q) / q);
|
||||
|
||||
//return location-scale*log(q/(1-q));
|
||||
//return location-scale*log1p((2*q-1)/(1-q));
|
||||
|
||||
@@ -51,14 +51,13 @@ namespace boost
|
||||
T pois = gamma_p_derivative(T(k+1), l2, pol);
|
||||
if(pois == 0)
|
||||
return init_val;
|
||||
// recurance term:
|
||||
T xterm;
|
||||
// Starting beta term:
|
||||
T beta = x < y
|
||||
? ibeta(a + k, b, x, pol)
|
||||
: ibetac(b, a + k, y, pol);
|
||||
// recurance term:
|
||||
T xterm = x < y
|
||||
? ibeta_derivative(a + k, b, x, pol)
|
||||
: ibeta_derivative(b, a + k, y, pol);
|
||||
? detail::ibeta_imp(T(a + k), b, x, pol, false, true, &xterm)
|
||||
: detail::ibeta_imp(b, T(a + k), y, pol, true, true, &xterm);
|
||||
|
||||
xterm *= y / (a + b + k - 1);
|
||||
T poisf(pois), betaf(beta), xtermf(xterm);
|
||||
T sum = init_val;
|
||||
@@ -130,14 +129,13 @@ namespace boost
|
||||
T pois = gamma_p_derivative(T(k+1), l2, pol);
|
||||
if(pois == 0)
|
||||
return init_val;
|
||||
// recurance term:
|
||||
T xterm;
|
||||
// Starting beta term:
|
||||
T beta = x < y
|
||||
? ibetac(a + k, b, x, pol)
|
||||
: ibeta(b, a + k, y, pol);
|
||||
// recurance term:
|
||||
T xterm = x < y
|
||||
? ibeta_derivative(a + k, b, x, pol)
|
||||
: ibeta_derivative(b, a + k, y, pol);
|
||||
? detail::ibeta_imp(T(a + k), b, x, pol, true, true, &xterm)
|
||||
: detail::ibeta_imp(b, T(a + k), y, pol, false, true, &xterm);
|
||||
|
||||
xterm *= y / (a + b + k - 1);
|
||||
T poisf(pois), betaf(beta), xtermf(xterm);
|
||||
T sum = init_val;
|
||||
|
||||
@@ -47,14 +47,13 @@ namespace boost
|
||||
* delta / constants::root_two<T>();
|
||||
if(pois == 0)
|
||||
return init_val;
|
||||
// Recurance term:
|
||||
T xterm;
|
||||
// Starting beta term:
|
||||
T beta = x < y
|
||||
? ibeta(T(k + 1), n / 2, x, pol)
|
||||
: ibetac(n / 2, T(k + 1), y, pol);
|
||||
// Recurance term:
|
||||
T xterm = x < y
|
||||
? ibeta_derivative(T(k + 1), n / 2, x, pol)
|
||||
: ibeta_derivative(n / 2, T(k + 1), y, pol);
|
||||
? detail::ibeta_imp(T(k + 1), T(n / 2), x, pol, false, true, &xterm)
|
||||
: detail::ibeta_imp(T(n / 2), T(k + 1), y, pol, true, true, &xterm);
|
||||
|
||||
xterm *= y / (n / 2 + k);
|
||||
T poisf(pois), betaf(beta), xtermf(xterm);
|
||||
T sum = init_val;
|
||||
@@ -118,14 +117,13 @@ namespace boost
|
||||
* delta / constants::root_two<T>();
|
||||
if(pois == 0)
|
||||
return init_val;
|
||||
// Recurance term:
|
||||
T xterm;
|
||||
// Starting beta term:
|
||||
T beta = x < y
|
||||
? ibetac(T(k + 1), n / 2, x, pol)
|
||||
: ibeta(n / 2, T(k + 1), y, pol);
|
||||
// Recurance term:
|
||||
T xterm = x < y
|
||||
? ibeta_derivative(T(k + 1), n / 2, x, pol)
|
||||
: ibeta_derivative(n / 2, T(k + 1), y, pol);
|
||||
? detail::ibeta_imp(T(k + 1), T(n / 2), x, pol, true, true, &xterm)
|
||||
: detail::ibeta_imp(T(n / 2), T(k + 1), y, pol, false, true, &xterm);
|
||||
|
||||
xterm *= y / (n / 2 + k);
|
||||
T poisf(pois), betaf(beta), xtermf(xterm);
|
||||
T sum = init_val;
|
||||
|
||||
@@ -274,6 +274,8 @@ BOOST_MATH_DISTRIBUTION1_TEST(chi_squared, int_values, real_values, probabilitie
|
||||
BOOST_MATH_DISTRIBUTION1_TEST(exponential, real_values, real_values, probabilities)
|
||||
BOOST_MATH_DISTRIBUTION2_TEST(fisher_f, int_values, int_values, real_values, probabilities)
|
||||
BOOST_MATH_DISTRIBUTION2_TEST(gamma, real_values, real_values, real_values, probabilities)
|
||||
BOOST_MATH_DISTRIBUTION3_TEST(hypergeometric, small_int_values, small_int_values, small_int_values, small_int_values, probabilities)
|
||||
BOOST_MATH_DISTRIBUTION2_TEST(logistic, real_values, real_values, real_values, probabilities)
|
||||
BOOST_MATH_DISTRIBUTION2_TEST(lognormal, real_values, real_values, real_values, probabilities)
|
||||
BOOST_MATH_DISTRIBUTION2_TEST(negative_binomial, int_values, probabilities, int_values, probabilities)
|
||||
BOOST_MATH_DISTRIBUTION2_TEST(normal, real_values, real_values, real_values, probabilities)
|
||||
@@ -494,6 +496,33 @@ double qnchisq(double, double, double, int, int)
|
||||
set_call_count(a_size * c_size);\
|
||||
}
|
||||
|
||||
double qhypergeo(double r, double n, double N, double p, int i, int j)
|
||||
{
|
||||
if(r > N)
|
||||
return std::numeric_limits<double>::quiet_NaN();
|
||||
double nr = r;
|
||||
double nb = N - r;
|
||||
return qhyper(nr, nb, n, p, i, j);
|
||||
}
|
||||
|
||||
double phypergeo(double r, double n, double N, double k, int i, int j)
|
||||
{
|
||||
if((r > N) || (k > n) || (k > r))
|
||||
return std::numeric_limits<double>::quiet_NaN();
|
||||
double nr = r;
|
||||
double nb = N - r;
|
||||
return phyper(nr, nb, n, k, i, j);
|
||||
}
|
||||
|
||||
double dhypergeo(double r, double n, double N, double k, int i)
|
||||
{
|
||||
if((r > N) || (k > n) || (k > r))
|
||||
return std::numeric_limits<double>::quiet_NaN();
|
||||
double nr = r;
|
||||
double nb = N - r;
|
||||
return dhyper(nr, nb, n, k, i);
|
||||
}
|
||||
|
||||
BOOST_MATH_R_DISTRIBUTION2_TEST(beta, probabilities, probabilities, probabilities, probabilities)
|
||||
BOOST_MATH_R_DISTRIBUTION2_TEST(binom, int_values, probabilities, int_values, probabilities)
|
||||
BOOST_MATH_R_DISTRIBUTION2_TEST(cauchy, int_values, real_values, int_values, probabilities)
|
||||
@@ -501,6 +530,8 @@ BOOST_MATH_R_DISTRIBUTION1_TEST(chisq, int_values, real_values, probabilities)
|
||||
BOOST_MATH_R_DISTRIBUTION1_TEST(exp, real_values, real_values, probabilities)
|
||||
BOOST_MATH_R_DISTRIBUTION2_TEST(f, int_values, int_values, real_values, probabilities)
|
||||
BOOST_MATH_R_DISTRIBUTION2_TEST(gamma, real_values, real_values, real_values, probabilities)
|
||||
BOOST_MATH_R_DISTRIBUTION3_TEST(hypergeo, small_int_values, small_int_values, small_int_values, small_int_values, probabilities)
|
||||
BOOST_MATH_R_DISTRIBUTION2_TEST(logis, real_values, real_values, real_values, probabilities)
|
||||
BOOST_MATH_R_DISTRIBUTION2_TEST(lnorm, real_values, real_values, real_values, probabilities)
|
||||
BOOST_MATH_R_DISTRIBUTION2_TEST(nbinom, int_values, probabilities, int_values, probabilities)
|
||||
BOOST_MATH_R_DISTRIBUTION2_TEST(norm, real_values, real_values, real_values, probabilities)
|
||||
|
||||
@@ -29,6 +29,7 @@ std::map<std::string, double> times;
|
||||
std::set<test_info> tests;
|
||||
double total = 0;
|
||||
int call_count = 0;
|
||||
bool compiler_prefix = false;
|
||||
|
||||
std::set<test_info>& all_tests()
|
||||
{
|
||||
@@ -69,8 +70,24 @@ void run_tests()
|
||||
std::set<test_info>::const_iterator i, j;
|
||||
for(i = tests.begin(), j = tests.end(); i != j; ++i)
|
||||
{
|
||||
std::string name;
|
||||
if(compiler_prefix)
|
||||
{
|
||||
#if defined(BOOST_MSVC) && !defined(_DEBUG) && !defined(__ICL)
|
||||
name = "msvc-";
|
||||
#elif defined(BOOST_MSVC) && defined(_DEBUG) && !defined(__ICL)
|
||||
name = "msvc-debug-";
|
||||
#elif defined(__GNUC__)
|
||||
name = "gcc-";
|
||||
#elif defined(__ICL)
|
||||
name = "intel-";
|
||||
#elif defined(__ICC)
|
||||
name = "intel-linux-";
|
||||
#endif
|
||||
}
|
||||
name += i->name;
|
||||
set_call_count(1);
|
||||
std::cout << "Testing " << std::left << std::setw(40) << i->name << std::flush;
|
||||
std::cout << "Testing " << std::left << std::setw(50) << name << std::flush;
|
||||
double time = performance_measure(i->proc) - reference_time;
|
||||
time /= call_count;
|
||||
std::cout << std::setprecision(3) << std::scientific << time << std::endl;
|
||||
@@ -172,6 +189,10 @@ int main(int argc, const char** argv)
|
||||
++a;
|
||||
}
|
||||
}
|
||||
else if(std::strcmp(argv[i], "--compiler-prefix") == 0)
|
||||
{
|
||||
compiler_prefix = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
116
performance/msvc-9-dist.log
Normal file
116
performance/msvc-9-dist.log
Normal file
@@ -0,0 +1,116 @@
|
||||
Testing msvc-dist-beta-R-cdf 1.271e-006
|
||||
Testing msvc-dist-beta-R-pdf 1.267e-006
|
||||
Testing msvc-dist-beta-R-quantile 3.347e-004
|
||||
Testing msvc-dist-beta-cdf 1.683e-006
|
||||
Testing msvc-dist-beta-pdf 7.005e-007
|
||||
Testing msvc-dist-beta-quantile 5.695e-006
|
||||
Testing msvc-dist-binom-R-cdf 7.714e-007
|
||||
Testing msvc-dist-binom-R-pdf 6.465e-007
|
||||
Testing msvc-dist-binom-R-quantile 3.770e-006
|
||||
Testing msvc-dist-binomial-cdf 5.276e-007
|
||||
Testing msvc-dist-binomial-pdf 5.760e-007
|
||||
Testing msvc-dist-binomial-quantile 3.608e-006
|
||||
Testing msvc-dist-cauchy-R-cdf 1.229e-007
|
||||
Testing msvc-dist-cauchy-R-pdf 5.145e-008
|
||||
Testing msvc-dist-cauchy-R-quantile 1.213e-007
|
||||
Testing msvc-dist-cauchy-cdf 1.878e-007
|
||||
Testing msvc-dist-cauchy-pdf 1.320e-007
|
||||
Testing msvc-dist-cauchy-quantile 1.997e-007
|
||||
Testing msvc-dist-chi_squared-cdf 6.258e-007
|
||||
Testing msvc-dist-chi_squared-pdf 5.354e-007
|
||||
Testing msvc-dist-chi_squared-quantile 3.934e-006
|
||||
Testing msvc-dist-chisq-R-cdf 1.196e-006
|
||||
Testing msvc-dist-chisq-R-pdf 5.232e-007
|
||||
Testing msvc-dist-chisq-R-quantile 5.271e-006
|
||||
Testing msvc-dist-exp-R-cdf 2.258e-007
|
||||
Testing msvc-dist-exp-R-pdf 2.725e-007
|
||||
Testing msvc-dist-exp-R-quantile 6.398e-008
|
||||
Testing msvc-dist-exponential-cdf 1.017e-007
|
||||
Testing msvc-dist-exponential-pdf 1.028e-007
|
||||
Testing msvc-dist-exponential-quantile 1.079e-007
|
||||
Testing msvc-dist-f-R-cdf 1.296e-006
|
||||
Testing msvc-dist-f-R-pdf 8.458e-007
|
||||
Testing msvc-dist-f-R-quantile 9.474e-006
|
||||
Testing msvc-dist-fisher_f-cdf 1.114e-006
|
||||
Testing msvc-dist-fisher_f-pdf 7.385e-007
|
||||
Testing msvc-dist-fisher_f-quantile 8.604e-006
|
||||
Testing msvc-dist-gamma-R-cdf 1.303e-006
|
||||
Testing msvc-dist-gamma-R-pdf 7.637e-007
|
||||
Testing msvc-dist-gamma-R-quantile 1.110e-005
|
||||
Testing msvc-dist-gamma-cdf 8.750e-007
|
||||
Testing msvc-dist-gamma-pdf 6.562e-007
|
||||
Testing msvc-dist-gamma-quantile 4.449e-006
|
||||
Testing msvc-dist-hypergeo-R-cdf 1.668e-007
|
||||
Testing msvc-dist-hypergeo-R-pdf 2.412e-007
|
||||
Testing msvc-dist-hypergeo-R-quantile 2.004e-006
|
||||
Testing msvc-dist-hypergeometric-cdf 2.583e-007
|
||||
Testing msvc-dist-hypergeometric-pdf 2.513e-007
|
||||
Testing msvc-dist-hypergeometric-quantile 2.369e-007
|
||||
Testing msvc-dist-lnorm-R-cdf 2.180e-007
|
||||
Testing msvc-dist-lnorm-R-pdf 3.315e-007
|
||||
Testing msvc-dist-lnorm-R-quantile 6.086e-007
|
||||
Testing msvc-dist-logis-R-cdf 3.623e-007
|
||||
Testing msvc-dist-logis-R-pdf 2.886e-007
|
||||
Testing msvc-dist-logis-R-quantile 8.211e-008
|
||||
Testing msvc-dist-logistic-cdf 1.550e-007
|
||||
Testing msvc-dist-logistic-pdf 1.667e-007
|
||||
Testing msvc-dist-logistic-quantile 1.534e-007
|
||||
Testing msvc-dist-lognormal-cdf 2.754e-007
|
||||
Testing msvc-dist-lognormal-pdf 2.686e-007
|
||||
Testing msvc-dist-lognormal-quantile 4.811e-007
|
||||
Testing msvc-dist-nbeta-R-cdf 1.071e-006
|
||||
Testing msvc-dist-nbeta-R-pdf 2.200e-006
|
||||
Testing msvc-dist-nbeta-R-quantile 7.591e-004
|
||||
Testing msvc-dist-nbinom-R-cdf 1.398e-006
|
||||
Testing msvc-dist-nbinom-R-pdf 1.023e-006
|
||||
Testing msvc-dist-nbinom-R-quantile 3.704e-004
|
||||
Testing msvc-dist-nchisq-R-cdf 1.457e-004
|
||||
Testing msvc-dist-nchisq-R-pdf 2.324e-006
|
||||
Testing msvc-dist-nchisq-R-quantile 2.671e-002
|
||||
Testing msvc-dist-negative_binomial-cdf 1.903e-006
|
||||
Testing msvc-dist-negative_binomial-pdf 2.019e-006
|
||||
Testing msvc-dist-negative_binomial-quantile 2.311e-005
|
||||
Testing msvc-dist-nf-R-cdf 1.781e-005
|
||||
Testing msvc-dist-nf-R-pdf 3.690e-005
|
||||
Testing msvc-dist-nf-R-quantile 1.924e-003
|
||||
Testing msvc-dist-non_central_beta-cdf 2.862e-006
|
||||
Testing msvc-dist-non_central_beta-pdf 3.559e-006
|
||||
Testing msvc-dist-non_central_beta-quantile 4.800e-004
|
||||
Testing msvc-dist-non_central_chi_squared-cdf 4.274e-006
|
||||
Testing msvc-dist-non_central_chi_squared-pdf 2.732e-005
|
||||
Testing msvc-dist-non_central_chi_squared-quantile 3.528e-004
|
||||
Testing msvc-dist-non_central_f-cdf 1.182e-005
|
||||
Testing msvc-dist-non_central_f-pdf 1.120e-005
|
||||
Testing msvc-dist-non_central_f-quantile 4.822e-004
|
||||
Testing msvc-dist-non_central_t-cdf 1.937e-005
|
||||
Testing msvc-dist-non_central_t-pdf 1.705e-005
|
||||
Testing msvc-dist-non_central_t-quantile 5.933e-004
|
||||
Testing msvc-dist-norm-R-cdf 1.372e-007
|
||||
Testing msvc-dist-norm-R-pdf 3.223e-007
|
||||
Testing msvc-dist-norm-R-quantile 1.182e-007
|
||||
Testing msvc-dist-normal-cdf 1.667e-007
|
||||
Testing msvc-dist-normal-pdf 2.588e-007
|
||||
Testing msvc-dist-normal-quantile 2.323e-007
|
||||
Testing msvc-dist-nt-R-cdf 5.411e-006
|
||||
Testing msvc-dist-nt-R-pdf 1.216e-005
|
||||
Testing msvc-dist-nt-R-quantile 4.432e-004
|
||||
Testing msvc-dist-pois-R-cdf 1.325e-006
|
||||
Testing msvc-dist-pois-R-pdf 7.679e-007
|
||||
Testing msvc-dist-pois-R-quantile 2.683e-006
|
||||
Testing msvc-dist-poisson-cdf 6.680e-007
|
||||
Testing msvc-dist-poisson-pdf 5.432e-007
|
||||
Testing msvc-dist-poisson-quantile 1.532e-006
|
||||
Testing msvc-dist-students_t-cdf 1.002e-006
|
||||
Testing msvc-dist-students_t-pdf 6.403e-007
|
||||
Testing msvc-dist-students_t-quantile 2.444e-006
|
||||
Testing msvc-dist-t-R-cdf 9.277e-007
|
||||
Testing msvc-dist-t-R-pdf 6.325e-007
|
||||
Testing msvc-dist-t-R-quantile 3.159e-006
|
||||
Testing msvc-dist-weibull-R-cdf 4.404e-007
|
||||
Testing msvc-dist-weibull-R-pdf 5.869e-007
|
||||
Testing msvc-dist-weibull-R-quantile 1.114e-006
|
||||
Testing msvc-dist-weibull-cdf 7.061e-007
|
||||
Testing msvc-dist-weibull-pdf 9.844e-007
|
||||
Testing msvc-dist-weibull-quantile 1.133e-006
|
||||
|
||||
|
||||
@@ -39,6 +39,9 @@ int main(int argc, const char* argv[])
|
||||
extra_text["msvc-dist-nbinom-R-quantile"] = "[footnote The R library appears to use a linear-search strategy, that can perform very badly in a small number of pathological cases, but may or may not be more efficient in \"typical\" cases]";
|
||||
extra_text["gcc-4_2-dist-beta-R-quantile"] = "[footnote There are a small number of our test cases where the R library fails to converge on a result: these tend to dominate the performance result.]";
|
||||
extra_text["gcc-4_2-dist-nbinom-R-quantile"] = "[footnote The R library appears to use a linear-search strategy, that can perform very badly in a small number of pathological cases, but may or may not be more efficient in \"typical\" cases]";
|
||||
extra_text["msvc-dist-hypergeometric-cdf"] = "[footnote This result is somewhat misleading: for small values of the parameters there is virtually no difference between the two libraries, but for large values the Boost implementation is /much/ slower, albeit with much improved precision.]";
|
||||
extra_text["msvc-dist-nt-R-quantile"] = "[footnote There are a small number of our test cases where the R library fails to converge on a result: these tend to dominate the performance result.]";
|
||||
|
||||
boost::regex e("^Testing\\s+(\\S+)\\s+(\\S+)");
|
||||
std::string f;
|
||||
for(int i = 1; i < argc-1; ++i)
|
||||
@@ -57,7 +60,14 @@ int main(int argc, const char* argv[])
|
||||
//
|
||||
std::ifstream is(argv[argc-1]);
|
||||
std::ofstream os(std::string(argv[argc-1]).append(".bak").c_str());
|
||||
e.assign("\\[perf\\s+([^\\s.]+)(?:\\[[^\\]]*\\]|[^\\]])*\\]");
|
||||
e.assign(
|
||||
"\\[perf\\s+([^\\s.]+)"
|
||||
"(?:"
|
||||
"\\[[^\\]\\[]*"
|
||||
"(?:\\[[^\\]\\[]*\\][^\\]\\[]*)?"
|
||||
"\\]"
|
||||
"|[^\\]]"
|
||||
")*\\]");
|
||||
std::string newfile;
|
||||
while(is.good())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user