public final class Maths extends Object
| Modifier and Type | Field and Description |
|---|---|
static double |
PI_BY_2
Constant for π/2.
|
static double |
SQRT_2
The precomputed √2.
|
static double |
SQRT_2PI
The precomputed √2π.
|
static double |
TO_DEGREES
Conversion multiplier for radians to degrees.
|
static double |
TO_RADIANS
Conversion multiplier for degrees to radians.
|
static double |
TWO_PI
Constant for 2π.
|
| Modifier and Type | Method and Description |
|---|---|
static Converter<Double,Double> |
decimalToProbabilityConverter(int percentScale)
Return a converter between decimal values and percentages.
|
static double |
epsilon(double μ,
double σ,
double x)
Standardized normal variate
ε = (x - μ) / σ. |
static double |
erf(double x)
Error function approximation of Abramowitz and Stegun, formula 7.1.26 in
the Handbook of Mathematical Functions with Formulas, Graphs, and
Mathematical Tables.
|
static double |
hypot(double... values)
Variadic form of
hypot(double, double). |
static double |
hypot(double v1,
double v2)
Same as
Math.hypot(double, double) without regard to intermediate
under/over flow prior to internal call to Math.sqrt(double). |
static double |
hypot(double v1,
double v2,
double v3)
Three argument form of
hypot(double, double). |
static double |
normalCcdf(double μ,
double σ,
double x)
Normal complementary cumulative distribution function.
|
static double |
normalPdf(double μ,
double σ,
double x)
Normal probability density function.
|
static double |
round(double value,
double model)
Round a double to the nearest specified double.
|
static double |
round(double value,
double model,
RoundingMode mode)
Round a double to the nearest specified double.
|
static double |
round(double value,
int scale)
Round a double to a specified number of decimal places according to
RoundingMode.HALF_UP. |
static double |
round(double value,
int scale,
RoundingMode mode)
Round a double to a specified number of decimal places according to the
supplied
RoundingMode. |
static double |
stepFunction(double μ,
double x)
Step function for which
f(x) = {
1 if x ≤ μ; 0 if x > μ }. |
public static final double PI_BY_2
public static final double TWO_PI
public static final double TO_RADIANS
public static final double TO_DEGREES
public static final double SQRT_2
public static final double SQRT_2PI
public static double epsilon(double μ,
double σ,
double x)
ε = (x - μ) / σ.μ - meanσ - standard deviationpublic static double erf(double x)
x ≥ 0, because erf(x) is an odd function,
erf(x) = −erf(−x) and negative values are supported.public static double hypot(double v1,
double v2)
Math.hypot(double, double) without regard to intermediate
under/over flow prior to internal call to Math.sqrt(double).v1 - first valuev2 - second valueMath.hypot(double, double)public static double hypot(double v1,
double v2,
double v3)
hypot(double, double). Does not
protect against intermediate under/over flow prior to internal call to
Math.sqrt(double).v1 - first valuev2 - second valuev3 - second valuehypot(double, double)public static double hypot(double... values)
hypot(double, double). Does not protect
against intermediate under/over flow prior to internal call to
Math.sqrt(double).values - to processhypot(double, double)public static double normalCcdf(double μ,
double σ,
double x)
μ - meanσ - standard deviationx - variatepublic static double normalPdf(double μ,
double σ,
double x)
μ - meanσ - standard deviationx - variatepublic static double stepFunction(double μ,
double x)
f(x) = {
1 if x ≤ μ; 0 if x > μ }.μ - meanx - variatepublic static double round(double value,
int scale)
RoundingMode.HALF_UP. Internally this method uses the scaling and
rounding capabilities of BigDecimal. Note that a negative
scale will round value to the specified number of places
above the decimal.value - to roundscale - the number of decimal places in the resultpublic static double round(double value,
int scale,
RoundingMode mode)
RoundingMode. Internally this method uses the scaling and
rounding capabilities of BigDecimal. Note that a negative
scale will round value to the specified number of places
above the decimal.value - to roundscale - the number of decimal places in the resultpublic static double round(double value,
double model)
BigDecimal according to
RoundingMode.HALF_UP.value - to roundmodel - to round topublic static double round(double value,
double model,
RoundingMode mode)
BigDecimal according to a specified
RoundingMode.value - to roundmodel - to round tomode - to round bypublic static Converter<Double,Double> decimalToProbabilityConverter(int percentScale)
decimalToProbabilityConverter(2).convert(0.23456) = 23.46
Reverse operations do not affect precision at this time.
percentScale - the number of decimal places in percentages output by
this converter