Class ExtendedPrecision
- java.lang.Object
-
- org.apache.commons.statistics.distribution.ExtendedPrecision
-
final class ExtendedPrecision extends java.lang.Object
Computes extended precision floating-point operations.Extended precision computation is delegated to the
DD
class. The methods here verify the arguments to the computations will not overflow.
-
-
Field Summary
Fields Modifier and Type Field Description private static double
BIG
Threshold for a big number that may overflow when squared.private static int
EXP_M_HALF_XX_MAX_VALUE
Approximate x squared value whereexp(-0.5*x*x) == 0
.private static int
EXP_M_HALF_XX_MIN_VALUE
X squared value whereexp(-0.5*x*x)
cannot increase accuracy using the round-off from x squared.private static double
SCALE_DOWN
Scale down by 2^600.private static double
SCALE_UP
Scale up by 2^600.private static double
SMALL
Threshold for a small number that may underflow when squared.(package private) static org.apache.commons.numbers.core.DD
SQRT2PI
sqrt(2 pi) as a double-double number.
-
Constructor Summary
Constructors Modifier Constructor Description private
ExtendedPrecision()
No instances.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static double
computeSqrt2aa(double a)
Computesqrt(2 * a * a)
.private static double
computeXsqrt2pi(double a)
Computea * sqrt(2 * pi)
.(package private) static double
expmhxx(double x)
Computeexp(-0.5*x*x)
with high accuracy.private static double
expxx(double a, double b)
Computeexp(a+b)
with high accuracy assuminga+b = a
.(package private) static double
sqrt2xx(double x)
Computesqrt(2 * x * x)
.(package private) static double
xsqrt2pi(double x)
Multiply the term by sqrt(2 pi).
-
-
-
Field Detail
-
SQRT2PI
static final org.apache.commons.numbers.core.DD SQRT2PI
sqrt(2 pi) as a double-double number. Divided into two parts from the value sqrt(2 pi) computed to 64 decimal digits.
-
BIG
private static final double BIG
Threshold for a big number that may overflow when squared. 2^500.- See Also:
- Constant Field Values
-
SMALL
private static final double SMALL
Threshold for a small number that may underflow when squared. 2^-500.- See Also:
- Constant Field Values
-
SCALE_UP
private static final double SCALE_UP
Scale up by 2^600.- See Also:
- Constant Field Values
-
SCALE_DOWN
private static final double SCALE_DOWN
Scale down by 2^600.- See Also:
- Constant Field Values
-
EXP_M_HALF_XX_MIN_VALUE
private static final int EXP_M_HALF_XX_MIN_VALUE
X squared value whereexp(-0.5*x*x)
cannot increase accuracy using the round-off from x squared.- See Also:
- Constant Field Values
-
EXP_M_HALF_XX_MAX_VALUE
private static final int EXP_M_HALF_XX_MAX_VALUE
Approximate x squared value whereexp(-0.5*x*x) == 0
. This is above-2 * ln(2^-1074)
due to rounding performed within the exp function.- See Also:
- Constant Field Values
-
-
Method Detail
-
xsqrt2pi
static double xsqrt2pi(double x)
Multiply the term by sqrt(2 pi).- Parameters:
x
- Value (assumed to be positive)- Returns:
- x * sqrt(2 pi)
-
computeXsqrt2pi
private static double computeXsqrt2pi(double a)
Computea * sqrt(2 * pi)
.- Parameters:
a
- Value- Returns:
- the result
-
sqrt2xx
static double sqrt2xx(double x)
Computesqrt(2 * x * x)
.The result is computed using a high precision computation of
sqrt(2 * x * x)
avoiding underflow or overflow ofx
squared.- Parameters:
x
- Value (assumed to be positive)- Returns:
sqrt(2 * x * x)
-
computeSqrt2aa
private static double computeSqrt2aa(double a)
Computesqrt(2 * a * a)
.- Parameters:
a
- Value- Returns:
- the result
-
expmhxx
static double expmhxx(double x)
Computeexp(-0.5*x*x)
with high accuracy. This is performed using information in the round-off fromx*x
.This is accurate at large x to 1 ulp until exp(-0.5*x*x) is close to sub-normal. For very small exp(-0.5*x*x) the adjustment is sub-normal and bits can be lost in the adjustment for a max observed error of
< 2
ulp.At small x the accuracy cannot be improved over using exp(-0.5*x*x). This occurs at
x <= sqrt(2)
.- Parameters:
x
- Value- Returns:
- exp(-0.5*x*x)
- See Also:
- STATISTICS-52
-
expxx
private static double expxx(double a, double b)
Computeexp(a+b)
with high accuracy assuminga+b = a
.This is accurate at large positive a to 1 ulp. If a is negative and exp(a) is close to sub-normal a bit of precision may be lost when adjusting result as the adjustment is sub-normal (max observed error
< 2
ulp). For the use case of multiplication of a number less than 1 by exp(-x*x), a = -x*x, the result will be sub-normal and the rounding error is lost.At small |a| the accuracy cannot be improved over using exp(a) as the round-off is too small to create terms that can adjust the standard result by more than 0.5 ulp. This occurs at
|a| <= 1
.- Parameters:
a
- High bits of a split numberb
- Low bits of a split number- Returns:
- exp(a+b)
- See Also:
- Numbers-177: Accurate scaling by exp(z*z)
-
-