|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object prefuse.util.MathLib
public class MathLib
Library of mathematical constants and methods not included in the
Math
class.
Field Summary | |
---|---|
static double |
LOG10
The natural logarithm of 10 |
static double |
LOG2
The natural logarithm of 2 |
static double |
TWO_PI
The value 2 * PI |
Method Summary | |
---|---|
static double |
interp(int scale,
double val,
double[] dist)
Interpolates a value within a range using a specified scale, returning the fractional position of the value within that scale. |
static double |
linearInterp(double val,
double min,
double max)
Interpolates a value between a given minimum and maximum value using a linear scale. |
static double |
log10(double x)
The base 10 logarithm of the input value |
static double |
log2(double x)
The base 2 logarithm of the input value |
static double |
logInterp(double val,
double min,
double max)
Interpolates a value between a given minimum and maximum value using a base-10 logarithmic scale. |
static double |
quantile(double val,
double[] quantiles)
Get the quantile measure, as a value between 0 and 1, for a given value and set of quantile boundaries. |
static double[] |
quantiles(int n,
double[] values)
Compute the n-quantile boundaries for a set of values. |
static double |
safeLog10(double x)
The "safe" base 10 logarithm of the input value, handling negative values by simply making them positive and then negating the return value. |
static double |
safeSqrt(double x)
The "safe" square root of the input value, handling negative values by simply making them positive and then negating the return value. |
static double |
sqrtInterp(double val,
double min,
double max)
Interpolates a value between a given minimum and maximum value using a square root scale. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final double TWO_PI
public static final double LOG10
public static final double LOG2
Method Detail |
---|
public static double log2(double x)
x
- the input value
public static double log10(double x)
x
- the input value
public static double safeLog10(double x)
x
- the input value
public static double safeSqrt(double x)
x
- the input value
public static double interp(int scale, double val, double[] dist)
scale
- The scale on which to perform the interpolation, one of
Constants.LINEAR_SCALE
,
Constants.LOG_SCALE
,
Constants.SQRT_SCALE
, or
Constants.QUANTILE_SCALE
.val
- the interpolation value, a fraction between 0 and 1.0.dist
- a double array describing the distribution of the data.
For the Constants.QUANTILE_SCALE
option, this should
be a collection of quantile boundaries, as determined by the
quantiles(int, double[])
method. For any other scale type,
the first value of the array must contain the minimum value of the
distribution and the last value of the array must contain the
maximum value of the distribution; all values in between will be
ignored.
public static double linearInterp(double val, double min, double max)
val
- the interpolation value, a fraction between 0 and 1.0.min
- the minimum value of the interpolation rangemax
- the maximum value of the interpolation range
public static double logInterp(double val, double min, double max)
val
- the interpolation value, a fraction between 0 and 1.0.min
- the minimum value of the interpolation rangemax
- the maximum value of the interpolation range
public static double sqrtInterp(double val, double min, double max)
val
- the interpolation value, a fraction between 0 and 1.0.min
- the minimum value of the interpolation rangemax
- the maximum value of the interpolation range
public static double[] quantiles(int n, double[] values)
n
- the number of quantile boundaries. For example, a value of 4
will break up the values into quartiles, while a value of 100 will break
up the values into percentiles.values
- the array of double values to divide into quantiles
public static double quantile(double val, double[] quantiles)
val
- the value for which to return the quantile rankingquantiles
- an array of quantile boundaries of a distribution
quantiles(int, double[])
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |