org.das2.util.DasMath
DasMath( )
Creates a new instance of DasMath
biggerOf
biggerOf( double x1, double x2 ) → double
returns the bigger number of two numbers
Parameters
x1 - a number
x2 - a number
Returns:
the greater of the two numbers
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
exp10
exp10( double x ) → double
Parameters
x - a double
Returns:
double
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
exp10( int x ) → double
findex
findex( double[][] datax, double[][] x ) → double[]
Returns the "floating point indeces" of x within array datax.
A floating point index (or "findex") indicates the indeces
of the points that bracket and the weights of each bracketing
point to use. A findex of 4.5 indicates that x is half-way
between index 4 and 5, so equal weights should be used.
floor( findex ) is the "left" bracket, ceil(findex) is the
"right" bracket, and fp( findex ) is the weight for the
right bracket. See interpolate for an example of its use.
Parameters
datax - a double[]
x - a double[]
Returns:
double[][]
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
findex( double[][] datax, double x, int guess ) → double
gcd
gcd( double[][] A, double error ) → double
Returns the greatest common divisor of a group of numbers. This is useful for
a number of visualization techniques, for instance when you need to integerize
your data, the binsize should be the gcd. An error parameter is provided to
avoid numerical noise, and in case there is a granularity that needn't be
surpassed.
org.das2.datum.DatumUtil has a private copy of this code.
Parameters
A - the array of numbers
error - the limit of the error to deal with numerical noise
Returns:
the greatest common divisor (GCD)
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
interpolate
interpolate( double[][] datay, double findex ) → double
Interpolate just one point
Parameters
datay - a double[]
findex - a double
Returns:
double
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
interpolate( double[][] datay, double[][] findex ) → double[]
log10
log10( double x ) → double
Parameters
x - a double
Returns:
double
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
main
main( java.lang.String[][] args ) → void
Parameters
args - a java.lang.String[]
Returns:
void (returns nothing)
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
max
max( double[][] A ) → double
return the maximum of the list
Parameters
A - the list of numbers
Returns:
the maximum of the list
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
mean
mean( double[][] A ) → double
return the mean of the list. The first element's magnitude is
removed from each accumulated value so that items with large offset
values (for example times) can be averaged. There is no checking
for NaNs or fill values.
Parameters
A - a double[]
Returns:
the mean of the list.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
median
median( double[][] A ) → double
return the median of the list length N, which is the value at index N/2 of
the sorted list. This does not return the average for even-length lists.
and there is no checking for NaNs or fill values.
Parameters
A - the list of numbers
Returns:
the median of the list
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
min
min( double[][] A ) → double
return the minimum of the list
Parameters
A - the list
Returns:
the minimum of the list
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
modp
modp( double x, double t ) → double
just like modulo (%) function, but negative numbers return positive phase.
Parameters
x - the numerator
t - the devisor
Returns:
the modulo, which will always be positive
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
modp( int x, int t ) → int
roundNFractionalDigits
roundNFractionalDigits( double x, int n ) → double
round the decimal to the number of fractional decimal places. For example,
DasMath.roundNFractionalDigits(1.2345678,3)==1.23
Note the name implies that there will be three decimals in the fractional
part, but this implementation will return only two.
Parameters
x - a double
n - number of decimal places
Returns:
the number rounded to the number of decimal places.
See Also:
roundNSignificantDigits(double, int)
https://github.com/autoplot/dev/blob/master/demos/2023/20230910/roundNDigits.jy
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
roundNSignificantDigits
roundNSignificantDigits( double x, int n ) → double
Round the double to n significant digits by removing the exponent to make the number order one,
then rounding the mantissa, then replacing the exponent.
Parameters
x - a double
n - number of decimal places
Returns:
the number rounded to the number of decimal places.
See Also:
roundNFractionalDigits(double, int)
https://github.com/autoplot/dev/blob/master/demos/2023/20230910/roundNDigits.jy
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
sort
sort( double[][] A ) → double[]
return a sorted version of the array. The original array is not
modified.
Parameters
A - a double[]
Returns:
return a sorted version of the array.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
tanh
tanh( double x ) → double
Parameters
x - a double
Returns:
double
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]