marytts.util.math

## Class MathUtils

• ```public class MathUtils
extends Object```
Author:
Marc Schröder, Oytun Tuerk An uninstantiable class, containing static utility methods in the Math domain.
• ### Field Summary

Fields
Modifier and Type Field and Description
`static int` `EQUALS`
`static int` `GREATER_THAN`
`static int` `GREATER_THAN_OR_EQUALS`
`static int` `LESS_THAN`
`static int` `LESS_THAN_OR_EQUALS`
`protected static double` `LOG10`
`static int` `NOT_EQUALS`
`protected static double` `PASCAL`
`protected static double` `PASCALSQUARE`
`static double` `TINY`
`static double` `TINY_LOG`
`static double` `TINY_PROBABILITY`
`static double` `TINY_PROBABILITY_LOG`
`static double` `TWOPI`
• ### Constructor Summary

Constructors
Constructor and Description
`MathUtils()`
• ### Method Summary

Methods
Modifier and Type Method and Description
`static double[]` `abs(ComplexArray c)`
`static double[]` ```abs(ComplexArray c, int startInd, int endInd)```
`static double[]` `abs(ComplexNumber[] x)`
`static double` `absMax(double[] data)`
Find the maximum of the absolute values of all elements in the array, ignoring elements that are NaN.
`static double` ```absMax(double[] data, int off, int len)```
Find the maximum of the absolute values of all elements in the given subarray, ignoring elements that are NaN.
`static double` `absMean(double[] x)`
`static double[][]` ```add(double[][] x, double[][] y)```
`static double[]` ```add(double[] a, double b)```
`static double[]` ```add(double[] x, double[] y)```
`static float[]` ```add(float[] a, float b)```
`static float[]` ```add(float[] a, float[] b)```
`static ComplexNumber` ```addComplex(ComplexNumber x1, ComplexNumber x2)```
`static ComplexNumber` ```addComplex(ComplexNumber x, double yReal, double yImag)```
`static ComplexNumber` ```addComplex(double yReal, double yImag, ComplexNumber x)```
`static ComplexNumber` ```addComplex(double xReal, double xImag, double yReal, double yImag)```
`static int[]` ```addIndex(int[] X, int x)```
Add val x to list of int X
`static void` ```adjustMean(double[] x, double newMean)```
`static void` ```adjustMeanStandardDeviation(double[] x, double newMean, double newStandardDeviation)```
`static void` ```adjustMeanStandardDeviation(double[] x, double currentMean, double newMean, double newStandardDeviation)```
`static void` ```adjustMeanVariance(double[] x, double newMean, double newVariance)```
`static void` ```adjustRange(double[] x, double minVal, double maxVal)```
`static void` ```adjustStandardDeviation(double[] x, double newStandardDeviation)```
`static void` ```adjustStandardDeviation(double[] x, double newStandardDeviation, double currentMean)```
`static void` ```adjustVariance(double[] x, double newVariance)```
`static void` ```adjustVariance(double[] x, double newVariance, double currentMean)```
`static boolean` `allZeros(double[] x)`
`static double` `amp2db(double amp)`
`static double[]` `amp2db(double[] amps)`
`static double` `amp2neper(double amp)`
`static double[]` `amp2neper(double[] amps)`
`static ComplexNumber` ```ampPhase2ComplexNumber(double amp, double phaseInRadians)```
`static double` `angleToDefaultAngle(double angle)`
For a given angle in radians, return the equivalent angle in the range [-PI, PI].
`static void` `angleToDefaultAngle(double[] angle)`
For each of an array of angles (in radians), return the equivalent angle in the range [-PI, PI].
`static double[]` ```arrayResize(double[] source, int targetSize)```
array resize to target size using linear interpolation
`static double[]` ```autocorr(double[] x, int P)```
`static double[]` `byteRange2DoubleRange(double[] x)`
`static double[]` ```byteRange2DoubleRange(double[] x, double doubleMin, double doubleMax)```
`static float[]` `byteRange2FloatRange(float[] x)`
`static float[]` ```byteRange2FloatRange(float[] x, float floatMin, float floatMax)```
`static double` ```CheckLimits(double val, double minVal, double maxVal)```
`static float` ```CheckLimits(float val, float minVal, float maxVal)```
`static int` ```CheckLimits(int val, int minVal, int maxVal)```
`static boolean` ```clipRange(double[] x, double minVal, double maxVal)```
Adjust values in x so that all values smaller than minVal are set to minVal, and all values greater than maxVal are set to maxVal
`static int` `closestPowerOfTwoAbove(int N)`
`static ComplexNumber` `complexConjugate(ComplexNumber x)`
`static ComplexNumber` ```complexConjugate(double xReal, double xImag)```
`static ComplexNumber` ```complexNumber(double r, double theta)```
`static double` ```correlation(double[] x, double[] y)```
Sample correlation coefficient Ref: http://en.wikipedia.org/wiki/Correlation_and_dependence
`static double[][]` `covariance(double[][] x)`
`static double[][]` ```covariance(double[][] x, boolean isAlongRows)```
`static double[][]` ```covariance(double[][] x, double[] meanVector)```
`static double[][]` ```covariance(double[][] x, double[] meanVector, boolean isAlongRows)```
`static double[][]` ```covariance(double[][] x, double[] meanVector, boolean isAlongRows, int[] indicesOfX)```
`static double` `db(double energy)`
Convert energy from linear scale to db scale.
`static double[]` `db(double[] energies)`
`static double` `db2amp(double dbAmplitude)`
`static double[]` `db2amp(double[] dbAmplitudes)`
`static float` `db2amp(float dbAmplitude)`
`static float[]` `db2amp(float[] dbAmplitudes)`
`static double` `db2linear(double dbEnergy)`
Convert energy from db scale to linear scale.
`static double[]` `db2linear(double[] dbEnergies)`
`static double` `db2neper(double db)`
`static double[]` `db2neper(double[] dbs)`
`static double` `dbSPL(double energy)`
Convert energy from linear scale to db SPL scale (comparing energies to the minimum audible energy, one Pascal squared).
`static double[]` `dbSPL(double[] energies)`
`static double` `degrees2radian(double deg)`
`static float` `degrees2radian(float deg)`
`static double` `determinant(double[] diagonal)`
`static double` `determinant(double[][] matrix)`
`static double[]` `dft2ampdb(ComplexArray c)`
`static double[]` ```dft2ampdb(ComplexArray c, int startInd, int endInd)```
`static double[]` `diagonal(double[][] x)`
`static ComplexNumber[][]` `diagonalComplexMatrix(double[] diag)`
`static double[][]` `diagonalMatrix(double[] diag)`
`static double[]` `diff(double[] a)`
Get first-order discrete difference along adjacent values in an array
`static ComplexNumber` ```divide(ComplexNumber x1, double x2)```
`static double[][]` ```divide(double[][] x, double a)```
`static double[]` ```divide(double[] a, double b)```
`static double[]` ```divide(double[] a, double[] b)```
`static ComplexNumber` ```divide(double x1, ComplexNumber x2)```
`static ComplexNumber` ```divideComplex(ComplexNumber x1, ComplexNumber x2)```
`static ComplexNumber` ```divideComplex(ComplexNumber x, double yReal, double yImag)```
`static ComplexNumber` ```divideComplex(double yReal, double yImag, ComplexNumber x)```
`static ComplexNumber` ```divideComplex(double xReal, double xImag, double yReal, double yImag)```
`static double[][]` ```dotProduct(double[][] x, double[][] y)```
`static double` ```dotProduct(double[] x, double[] y)```
`static double[]` `doubleRange2ByteRange(double[] x)`
`static double[]` ```doubleRange2ByteRange(double[] x, double doubleMin, double doubleMax)```
`static double` `euclidianLength(double[] a)`
`static double` `euclidianLength(float[] a)`
`static double[]` `exp(double[] a)`
`static double` `exp10(double x)`
`static double[]` `exp10(double[] a)`
`static int[][]` `factorialDesign(int[] totalItemsInNodes)`
`static double[]` ```filledArray(double val, int len)```
`static float[]` ```filledArray(float val, int len)```
`static int[]` ```filledArray(int val, int len)```
`static int[]` ```find(double[] x, int comparator, double val)```
`static int[]` ```find(int[] x, int comparator, int val)```
`static int[]` ```findAnd(double[] x, int comparator1, double val1, int comparator2, double val2)```
`static int[]` ```findAnd(int[] x, int comparator1, int val1, int comparator2, int val2)```
`static int` ```findClosest(float[] x, float val)```
`static int` ```findClosest(int[] x, int val)```
`static int` `findGlobalPeakLocation(double[] data)`
Find the maximum of all elements in the array, ignoring elements that are NaN.
`static int` `findGlobalPeakLocation(float[] data)`
Find the maximum of all elements in the array, ignoring elements that are NaN.
`static int` `findGlobalValleyLocation(double[] data)`
Find the minimum of all elements in the array, ignoring elements that are NaN.
`static int` `findGlobalValleyLocation(float[] data)`
Find the minimum of all elements in the array, ignoring elements that are NaN.
`static int` ```findNextIndexNonZero(double[] contour, int current)```
To find next NonZero index in a given array
`static int` ```findNextPeakLocation(double[] data, int startIndex)```
`static int` ```findNextValleyLocation(double[] data, int startIndex)```
`static int[]` ```findOr(double[] x, int comparator1, double val1, int comparator2, double val2)```
`static int[]` ```findOr(int[] x, int comparator1, int val1, int comparator2, int val2)```
`static double[]` ```findValues(double[] x, int comparator, double val)```
`static float[]` `floatRange2ByteRange(float[] x)`
`static float[]` ```floatRange2ByteRange(float[] x, float floatMin, float floatMax)```
`static double` `getAbsMax(double[] x)`
`static double` ```getAbsMax(double[] x, int startInd, int endInd)```
`static int` ```getAbsMaxInd(double[] x, int startInd, int endInd)```
`static double` `getConfidenceInterval95(double standardDeviation)`
`static double` `getConfidenceInterval99(double standardDeviation)`
`static int[]` ```getExtrema(double[] x, int[] numLeftNs, int[] numRightNs, boolean isMaxima)```
`static int[]` ```getExtrema(double[] x, int[] numLeftNs, int[] numRightNs, boolean isMaxima, int startInd)```
`static int[]` ```getExtrema(double[] x, int[] numLeftNs, int[] numRightNs, boolean isMaxima, int startInd, int endInd)```
`static int[]` ```getExtrema(double[] x, int[] numLeftNs, int[] numRightNs, boolean isMaxima, int startInd, int endInd, double th)```
`static int[]` ```getExtrema(double[] x, int numLeftN, int numRightN, boolean isMaxima)```
`static int[]` ```getExtrema(double[] x, int numLeftN, int numRightN, boolean isMaxima, int startInd)```
`static int[]` ```getExtrema(double[] x, int numLeftN, int numRightN, boolean isMaxima, int startInd, int endInd)```
`static int[]` ```getExtrema(double[] x, int numLeftN, int numRightN, boolean isMaxima, int startInd, int endInd, double th)```
`static int` ```getExtremaIndex(double[] x, boolean isMax)```
`static int` ```getExtremaIndex(double[] x, boolean isMax, int startInd)```
`static int` ```getExtremaIndex(double[] x, boolean isMax, int startInd, int endInd)```
`static int` ```getExtremaIndex(float[] x, boolean isMax)```
`static int` ```getExtremaIndex(float[] x, boolean isMax, int startInd)```
`static int` ```getExtremaIndex(float[] x, boolean isMax, int startInd, int endInd)```
`static int` ```getExtremaIndex(int[] x, boolean isMax)```
`static int` ```getExtremaIndex(int[] x, boolean isMax, int startInd)```
`static int` ```getExtremaIndex(int[] x, boolean isMax, int startInd, int endInd)```
`static double` ```getGaussianPdfValue(double[] x, double[] meanVector, double[] covarianceMatrix)```
`static double` ```getGaussianPdfValue(double[] x, double[] meanVector, double[][] inverseCovarianceMatrix, double constantTerm)```
`static double` ```getGaussianPdfValue(double[] x, double[] meanVector, double[] covarianceMatrix, double constantTerm)```
`static double` ```getGaussianPdfValue(double[] x, double[] meanVector, double detCovarianceMatrix, double[][] inverseCovarianceMatrix)```
`static double` ```getGaussianPdfValueConstantTerm(int featureDimension, double detCovarianceMatrix)```
`static double` ```getGaussianPdfValueConstantTermLog(int featureDimension, double detCovarianceMatrix)```
`static double` ```getGaussianPdfValueLog(double[] x, double[] meanVector, double[] covarianceMatrix, double constantTermLog)```
`static int` ```getLargestIndexSmallerThan(double[] x, double val)```
`static double` `getMax(double[] x)`
`static float` `getMax(float[] x)`
`static int` `getMax(int[] x)`
`static int` `getMaxIndex(double[] x)`
`static int` ```getMaxIndex(double[] x, int startInd)```
`static int` ```getMaxIndex(double[] x, int[] inds)```
`static int` ```getMaxIndex(double[] x, int startInd, int endInd)```
`static int` `getMaxIndex(float[] x)`
`static int` ```getMaxIndex(float[] x, int startInd)```
`static int` ```getMaxIndex(float[] x, int startInd, int endInd)```
`static int` `getMaxIndex(int[] x)`
`static int` ```getMaxIndex(int[] x, int startInd)```
`static int` ```getMaxIndex(int[] x, int startInd, int endInd)```
`static double` `getMin(double[] x)`
`static float` `getMin(float[] x)`
`static int` `getMin(int[] x)`
`static int` `getMinIndex(double[] x)`
`static int` ```getMinIndex(double[] x, int startInd)```
`static int` ```getMinIndex(double[] x, int startInd, int endInd)```
`static int` `getMinIndex(float[] x)`
`static int` ```getMinIndex(float[] x, int startInd)```
`static int` ```getMinIndex(float[] x, int startInd, int endInd)```
`static int` `getMinIndex(int[] x)`
`static int` ```getMinIndex(int[] x, int startInd)```
`static int` ```getMinIndex(int[] x, int startInd, int endInd)```
`static double[]` `getRandoms(int len)`
`static double[]` ```getRandoms(int len, double minVal, double maxVal)```
`static double` ```getSortedValue(double[] x, double percentSmallerThan)```
`static double[]` `getVarianceCols(double[][] x)`
`static double[]` `getVarianceRows(double[][] x)`
`static ComplexNumber[][]` `hermitianTranspoze(ComplexNumber[][] x)`
`static double[]` ```interpolate_linear(int[] x, double[] y, int[] xi)```
`static ComplexNumber[]` ```interpolate(ComplexNumber[] x, int newLength)```
`static double[]` ```interpolate(double[] x, int newLength)```
`static float[]` ```interpolate(float[] x, int newLength)```
`static double[]` ```interpolate(int[] xInds, double[] xVals, int[] xInds2)```
`static double` ```interpolatedSample(double xStart, double xVal, double xEnd, double yStart, double yEnd)```
`static double[]` `interpolateNonZeroValues(double[] contour)`
To interpolate Zero values with respect to NonZero values
`static ComplexNumber[]` `inverse(ComplexNumber[] x)`
`static ComplexNumber[][]` `inverse(ComplexNumber[][] matrix)`
`static double[]` `inverse(double[] x)`
`static double[][]` `inverse(double[][] matrix)`
`static void` `inverseInPlace(ComplexNumber[][] matrix)`
`static void` `inverseInPlace(double[][] matrix)`
`static double[]` `invert(double[] a)`
Returns the multiplicative inverse (element-wise 1/x) of an array
`static float[]` `invert(float[] a)`
`static boolean` `isAnyInfinity(double[] x)`
Check whether x contains Infinity
`static boolean` `isAnyNaN(double[] x)`
`static boolean` `isPowerOfTwo(int N)`
`static ComplexNumber[]` ```levinson(ComplexNumber[] r, ComplexNumber[] c)```
`static double[]` ```levinson(double[] r, int m)```
This is the Java source code for a Levinson Recursion.
`static double[]` `linear2db(double[] linears)`
`static double` ```linearMap(double x, double xStart, double xEnd, double yStart, double yEnd)```
`static float` ```linearMap(float x, float xStart, float xEnd, float yStart, float yEnd)```
`static int` ```linearMap(int x, int xStart, int xEnd, int yStart, int yEnd)```
`static double[]` `log(double[] a)`
`static double[]` ```log(double[] a, double minimumValue, double fixedValue)```
`static double` `log10(double x)`
`static double[]` `log10(double[] a)`
`static double` ```logAdd(double x, double y)```
`static void` ```luDecompose(ComplexNumber[][] a, int n, int[] indx, ComplexNumber[] d)```
`static void` ```luDecompose(double[][] a, int n, int[] indx, double[] d)```
`static void` ```luSubstitute(ComplexNumber[][] a, int[] indx, ComplexNumber[] b)```
`static void` ```luSubstitute(double[][] a, int[] indx, double[] b)```
`static double[]` `magnitudeComplex(ComplexArray x)`
`static double` `magnitudeComplex(ComplexNumber x)`
`static double[]` `magnitudeComplex(ComplexNumber[] xs)`
`static double` ```magnitudeComplex(double xReal, double xImag)```
`static double` `magnitudeComplexSquared(ComplexNumber x)`
`static double` ```magnitudeComplexSquared(double xReal, double xImag)```
`static void` `main(String[] args)`
`static ComplexNumber[]` ```matrixProduct(ComplexNumber[][] x, ComplexNumber[] y)```
`static ComplexNumber[][]` ```matrixProduct(ComplexNumber[][] x, ComplexNumber[][] y)```
`static ComplexNumber[]` ```matrixProduct(ComplexNumber[][] x, double[] y)```
`static ComplexNumber[][]` ```matrixProduct(ComplexNumber[] x, ComplexNumber[][] y)```
`static double[]` ```matrixProduct(double[][] x, double[] y)```
`static double[][]` ```matrixProduct(double[][] x, double[][] y)```
`static double[]` ```matrixProduct(double[][] x, float[] y)```
`static double[][]` ```matrixProduct(double[] x, double[][] y)```
`static double` `max(double[] data)`
Find the maximum of all elements in the array, ignoring elements that are NaN.
`static int` `max(int[] data)`
`static double` `mean(double[] data)`
`static double[]` `mean(double[][] x)`
`static double[]` ```mean(double[][] x, boolean isAlongRows)```
`static double[]` ```mean(double[][] x, boolean isAlongRows, int[] indicesOfX)```
`static double` ```mean(double[] data, int opt)```
Compute the mean of all elements in the array.
`static double` ```mean(double[] data, int[] inds)```
Compute the mean of all elements in the array with given indices.
`static double` ```mean(double[] data, int startIndex, int endIndex)```
Compute the mean of all elements in the array.
`static float` `mean(float[] data)`
`static float` ```mean(float[] data, int[] inds)```
Compute the mean of all elements in the array with given indices.
`static float` ```mean(float[] data, int startIndex, int endIndex)```
Compute the mean of all elements in the array.
`static double` `median(double[] x)`
`static double` ```median(double[] xin, int firstIndex, int lastIndex)```
`static double` `min(double[] data)`
Find the minimum of all elements in the array, ignoring elements that are NaN.
`static int` `min(int[] data)`
`static double[]` ```modifySize(double[] x, int newLen)```
`static double[]` ```multiply(double[] a, double b)```
`static double[]` ```multiply(double[] a, double[] b)```
`static ComplexNumber` ```multiply(double x1, ComplexNumber x2)```
`static double[][]` ```multiply(double a, double[][] x)```
`static float[]` ```multiply(float[] a, float b)```
`static float[]` ```multiply(float[] a, float[] b)```
`static ComplexNumber[]` ```multiplyComplex(ComplexNumber[] a, double b)```
`static ComplexNumber` ```multiplyComplex(ComplexNumber x1, ComplexNumber x2)```
`static ComplexNumber` ```multiplyComplex(ComplexNumber x, double yReal, double yImag)```
`static ComplexNumber` ```multiplyComplex(double yReal, double yImag, ComplexNumber x)```
`static ComplexNumber` ```multiplyComplex(double xReal, double xImag, double yReal, double yImag)```
`static double` `neper2db(double neper)`
`static double[]` `neper2db(double[] nepers)`
`static double` `neper2linear(double neper)`
`static double[]` `neper2linear(double[] nepers)`
`static double[]` ```normalizeToAbsMax(double[] x, double absMax)```
`static double[]` ```normalizeToRange(double[] x, int len, double minVal, double maxVal)```
`static double[]` ```normalizeToSumUpTo(double[] x, double sumUp)```
`static double[]` ```normalizeToSumUpTo(double[] x, int len, double sumUp)```
`static double[]` `normalizeZscore(double[] x)`
Calculates x_i = (x_i - mean(x)) / std(x) This function can deal with NaNs
`static double[]` `ones(int len)`
`static float[]` `onesFloat(int len)`
`static int[]` `onesInt(int len)`
`static double[]` `phaseInRadians(ComplexArray x)`
`static double` `phaseInRadians(ComplexNumber x)`
`static double[]` `phaseInRadians(ComplexNumber[] xs)`
`static double` ```phaseInRadians(double xReal, double xImag)```
`static float` `phaseInRadiansFloat(ComplexNumber x)`
`static float[]` `phaseInRadiansFloat(ComplexNumber[] xs)`
`static ComplexNumber[]` ```polar2complex(double[] amps, double[] phasesInRadian)```
`static ComplexNumber[]` ```polar2complex(double[] amps, float[] phasesInRadian)```
`static int[]` `quickSort(double[] x)`
`static void` ```quickSort(double[] x, int[] y)```
`static void` ```quickSort(double[] x, int[] y, int startIndex, int endIndex)```
`static int[]` ```quickSort(double[] x, int startIndex, int endIndex)```
`static int[]` `quickSort(float[] x)`
`static void` ```quickSort(float[] x, int[] y)```
`static void` ```quickSort(float[] x, int[] y, int startIndex, int endIndex)```
`static int[]` ```quickSort(float[] x, int startIndex, int endIndex)```
`static int[]` `quickSort(int[] x)`
`static double` `radian2degrees(double rad)`
`static float` `radian2degrees(float rad)`
`static double[]` `random(int numSamples)`
`static double[]` ```random(int numSamples, double minVal, double maxVal)```
`static double[][]` `randomSort(double[][] x)`
`static int[]` `randomSort(int[] x)`
`static int[]` ```removeIndex(int[] X, int x)```
Remove val x from list of int X
`static double` `sinc(double x)`
`static double[]` `sinc(double[] x)`
`static double` ```sinc(double x, double N)```
`static float` `sinc(float x)`
`static float[]` `sinc(float[] x)`
`static float[]` ```sinc(float[] x, float N)```
`static float` ```sinc(float x, float N)```
`static double[]` ```sortAs(double[] x, int[] sortedIndices)```
`static float[]` ```sortAs(float[] x, int[] sortedIndices)```
`static double` `standardDeviation(double[] data)`
`static double` ```standardDeviation(double[] data, double meanVal)```
`static double` ```standardDeviation(double[] data, double meanVal, int startIndex, int endIndex)```
`static double` ```standardDeviation(double[] data, int opt)```
Compute the standard deviation of the given data, this function can deal with NaNs
`static double[][]` ```subtract(double[][] x, double[][] y)```
`static double[]` ```subtract(double[] a, double b)```
`static double[]` ```subtract(double[] a, double[] b)```
`static float[]` ```subtract(float[] a, float b)```
`static float[]` ```subtract(float[] a, float[] b)```
`static ComplexNumber` ```subtractComplex(ComplexNumber x1, ComplexNumber x2)```
`static ComplexNumber` ```subtractComplex(ComplexNumber x, double yReal, double yImag)```
`static ComplexNumber` ```subtractComplex(double yReal, double yImag, ComplexNumber x)```
`static ComplexNumber` ```subtractComplex(double xReal, double xImag, double yReal, double yImag)```
`static double` `sum(double[] data)`
Build the sum of all elements in the array, ignoring elements that are NaN.
`static float` `sum(float[] data)`
`static int` `sum(int[] data)`
`static double` `sumSquared(double[] data)`
`static double` ```sumSquared(double[] data, double term)```
`static double` ```sumSquared(double[] data, int startInd, int endInd)```
`static double` ```sumSquared(double[] data, int startInd, int endInd, double term)```
`static double` ```sumSquaredError(double[] a, double[] b)```
Build the sum of the squared difference of all elements with the same index numbers in the arrays.
`static void` ```toCartesianCoordinates(double[] r, double[] phi)```
Convert a pair of arrays from polar (r, phi) coordinates to cartesian (x, y) coordinates.
`static double[][]` `toDiagonalMatrix(double[] x)`
`static void` ```toPolarCoordinates(double[] x, double[] y)```
Convert a pair of arrays from cartesian (x, y) coordinates to polar (r, phi) coordinates.
`static String` `toString(ComplexNumber[][] array)`
`static String[]` `toStringLines(ComplexArray x)`
`static String[]` `toStringLines(ComplexNumber[] x)`
`static ComplexNumber[][]` `transpoze(ComplexNumber[][] x)`
`static double[][]` `transpoze(double[] x)`
`static double[][]` `transpoze(double[][] x)`
`static double` ```trimToRange(double untrimmedValue, double min, double max)```
Trim the given value so that it is in the closed interval [min, max].
`static float` ```unwrap(float phaseInRadians, float prevPhaseInRadians)```
`static float` ```unwrapToRange(float phaseInDegrees, float lowestDegree)```
`static double` `variance(double[] data)`
`static double[]` ```variance(double[][] x, double[] meanVector)```
`static double[]` ```variance(double[][] x, double[] meanVector, boolean isAlongRows)```
Returns the variance of rows or columns of matrix x
`static double` ```variance(double[] data, double meanVal)```
`static double` ```variance(double[] data, double meanVal, int startIndex, int endIndex)```
`static double` ```variance(double[] data, int opt)```
Compute the variance in the array.
`static float` `variance(float[] data)`
`static float` ```variance(float[] data, float meanVal)```
`static float` ```variance(float[] data, float meanVal, int startIndex, int endIndex)```
`static double[][]` ```vectorProduct(double[] x, boolean isColumnVectorX, double[] y, boolean isColumnVectorY)```
`static double[]` `zeros(int len)`
`static float[]` `zerosFloat(int len)`
`static int[]` `zerosInt(int len)`
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Field Detail

• #### TINY_PROBABILITY

`public static final double TINY_PROBABILITY`
Constant Field Values
• #### TINY_PROBABILITY_LOG

`public static final double TINY_PROBABILITY_LOG`
• #### TINY

`public static final double TINY`
Constant Field Values
• #### TINY_LOG

`public static final double TINY_LOG`
• #### PASCAL

`protected static final double PASCAL`
Constant Field Values
• #### PASCALSQUARE

`protected static final double PASCALSQUARE`
Constant Field Values
• #### LOG10

`protected static final double LOG10`
• #### TWOPI

`public static final double TWOPI`
Constant Field Values
• #### EQUALS

`public static final int EQUALS`
Constant Field Values
• #### GREATER_THAN

`public static final int GREATER_THAN`
Constant Field Values
• #### GREATER_THAN_OR_EQUALS

`public static final int GREATER_THAN_OR_EQUALS`
Constant Field Values
• #### LESS_THAN

`public static final int LESS_THAN`
Constant Field Values
• #### LESS_THAN_OR_EQUALS

`public static final int LESS_THAN_OR_EQUALS`
Constant Field Values
• #### NOT_EQUALS

`public static final int NOT_EQUALS`
Constant Field Values
• ### Constructor Detail

• #### MathUtils

`public MathUtils()`
• ### Method Detail

• #### isPowerOfTwo

`public static boolean isPowerOfTwo(int N)`
• #### closestPowerOfTwoAbove

`public static int closestPowerOfTwoAbove(int N)`
• #### findNextValleyLocation

```public static int findNextValleyLocation(double[] data,
int startIndex)```
• #### findNextPeakLocation

```public static int findNextPeakLocation(double[] data,
int startIndex)```
• #### findGlobalPeakLocation

`public static int findGlobalPeakLocation(double[] data)`
Find the maximum of all elements in the array, ignoring elements that are NaN.
Parameters:
`data` - data
Returns:
the index number of the maximum element
• #### findGlobalPeakLocation

`public static int findGlobalPeakLocation(float[] data)`
Find the maximum of all elements in the array, ignoring elements that are NaN.
Parameters:
`data` - data
Returns:
the index number of the maximum element
• #### findGlobalValleyLocation

`public static int findGlobalValleyLocation(double[] data)`
Find the minimum of all elements in the array, ignoring elements that are NaN.
Parameters:
`data` - data
Returns:
the index number of the minimum element
• #### findGlobalValleyLocation

`public static int findGlobalValleyLocation(float[] data)`
Find the minimum of all elements in the array, ignoring elements that are NaN.
Parameters:
`data` - data
Returns:
the index number of the minimum element
• #### sum

`public static double sum(double[] data)`
Build the sum of all elements in the array, ignoring elements that are NaN.
Parameters:
`data` - data
Returns:
sum
• #### sum

`public static float sum(float[] data)`
• #### sum

`public static int sum(int[] data)`
• #### sumSquared

`public static double sumSquared(double[] data)`
• #### sumSquared

```public static double sumSquared(double[] data,
double term)```
• #### sumSquared

```public static double sumSquared(double[] data,
int startInd,
int endInd)```
• #### sumSquared

```public static double sumSquared(double[] data,
int startInd,
int endInd,
double term)```
• #### max

`public static double max(double[] data)`
Find the maximum of all elements in the array, ignoring elements that are NaN.
Parameters:
`data` - data
Returns:
max
• #### max

`public static int max(int[] data)`
• #### absMax

`public static double absMax(double[] data)`
Find the maximum of the absolute values of all elements in the array, ignoring elements that are NaN.
Parameters:
`data` - data
Returns:
absMax of data, 0, data.length
• #### absMax

```public static double absMax(double[] data,
int off,
int len)```
Find the maximum of the absolute values of all elements in the given subarray, ignoring elements that are NaN.
Parameters:
`data` - data
`off` - off
`len` - len
Returns:
max
• #### min

`public static double min(double[] data)`
Find the minimum of all elements in the array, ignoring elements that are NaN.
Parameters:
`data` - data
Returns:
min
• #### min

`public static int min(int[] data)`
• #### mean

`public static double mean(double[] data)`
• #### mean

```public static double mean(double[] data,
int startIndex,
int endIndex)```
Compute the mean of all elements in the array. No missing values (NaN) are allowed.
Parameters:
`data` - data
`startIndex` - start index
`endIndex` - end index
Returns:
mean
Throws:
`IllegalArgumentException` - if the array contains NaN values.
• #### mean

```public static double mean(double[] data,
int[] inds)```
Compute the mean of all elements in the array with given indices. No missing values (NaN) are allowed.
Parameters:
`data` - data
`inds` - inds
Returns:
mean
Throws:
`IllegalArgumentException` - if the array contains NaN values.
• #### mean

```public static float mean(float[] data,
int startIndex,
int endIndex)```
Compute the mean of all elements in the array. No missing values (NaN) are allowed.
Parameters:
`data` - data
`startIndex` - start index
`endIndex` - end index
Returns:
mean
Throws:
`IllegalArgumentException` - if the array contains NaN values.
• #### mean

`public static float mean(float[] data)`
• #### mean

```public static float mean(float[] data,
int[] inds)```
Compute the mean of all elements in the array with given indices. No missing values (NaN) are allowed.
Parameters:
`data` - data
`inds` - inds
Returns:
mean
Throws:
`IllegalArgumentException` - if the array contains NaN values.
• #### mean

```public static double mean(double[] data,
int opt)```
Compute the mean of all elements in the array. this function can deal with NaNs
Parameters:
`data` - double[]
`opt` - 0: arithmetic mean, 1: geometric mean
Returns:
math.exp(mean)
• #### standardDeviation

`public static double standardDeviation(double[] data)`
• #### standardDeviation

```public static double standardDeviation(double[] data,
double meanVal)```
• #### standardDeviation

```public static double standardDeviation(double[] data,
double meanVal,
int startIndex,
int endIndex)```
• #### standardDeviation

```public static double standardDeviation(double[] data,
int opt)```
Compute the standard deviation of the given data, this function can deal with NaNs
Parameters:
`data` - double[]
`opt` - 0: normalizes with N-1, this provides the square root of best unbiased estimator of the variance, 1: normalizes with N, this provides the square root of the second moment around the mean
Returns:
Math.sqrt(variance(data, opt))
• #### variance

```public static double variance(double[] data,
int opt)```
Compute the variance in the array. This function can deal with NaNs
Parameters:
`data` - double[]
`opt` - 0: normalizes with N-1, this provides the square root of best unbiased estimator of the variance, 1: normalizes with N, this provides the square root of the second moment around the mean
Returns:
S / numData -1 if opt is 0, S / numData otherwise
• #### variance

`public static double variance(double[] data)`
• #### variance

`public static float variance(float[] data)`
• #### variance

```public static double variance(double[] data,
double meanVal)```
• #### variance

```public static float variance(float[] data,
float meanVal)```
• #### variance

```public static float variance(float[] data,
float meanVal,
int startIndex,
int endIndex)```
• #### variance

```public static double variance(double[] data,
double meanVal,
int startIndex,
int endIndex)```
• #### variance

```public static double[] variance(double[][] x,
double[] meanVector)```
• #### variance

```public static double[] variance(double[][] x,
double[] meanVector,
boolean isAlongRows)```
Returns the variance of rows or columns of matrix x
Parameters:
`x` - the matrix consisting of row vectors
`meanVector` - the vector of mean values -- a column vector if row-wise variances are to be computed, or a row vector if column-wise variances are to be calculated. param isAlongRows if true, compute the variance of x[0][0], x[1][0] etc. given mean[0]; if false, compute the variances for the vectors x[0], x[1] etc. separately, given the respective mean[0], mean[1] etc.
`isAlongRows` - isAlongRows
Returns:
var
• #### mean

`public static double[] mean(double[][] x)`
• #### mean

```public static double[] mean(double[][] x,
boolean isAlongRows)```
• #### mean

```public static double[] mean(double[][] x,
boolean isAlongRows,
int[] indicesOfX)```
• #### covariance

`public static double[][] covariance(double[][] x)`
• #### covariance

```public static double[][] covariance(double[][] x,
double[] meanVector)```
• #### covariance

```public static double[][] covariance(double[][] x,
boolean isAlongRows)```
• #### covariance

```public static double[][] covariance(double[][] x,
double[] meanVector,
boolean isAlongRows)```
• #### covariance

```public static double[][] covariance(double[][] x,
double[] meanVector,
boolean isAlongRows,
int[] indicesOfX)```
• #### correlation

```public static double correlation(double[] x,
double[] y)```
Sample correlation coefficient Ref: http://en.wikipedia.org/wiki/Correlation_and_dependence
Parameters:
`x` - x
`y` - y
Returns:
r
• #### diagonal

`public static double[] diagonal(double[][] x)`
• #### toDiagonalMatrix

`public static double[][] toDiagonalMatrix(double[] x)`
• #### transpoze

`public static double[][] transpoze(double[] x)`
• #### transpoze

`public static double[][] transpoze(double[][] x)`
• #### transpoze

`public static ComplexNumber[][] transpoze(ComplexNumber[][] x)`
• #### hermitianTranspoze

`public static ComplexNumber[][] hermitianTranspoze(ComplexNumber[][] x)`
• #### diagonalComplexMatrix

`public static ComplexNumber[][] diagonalComplexMatrix(double[] diag)`
• #### diagonalMatrix

`public static double[][] diagonalMatrix(double[] diag)`
• #### ampPhase2ComplexNumber

```public static ComplexNumber ampPhase2ComplexNumber(double amp,
• #### polar2complex

```public static ComplexNumber[] polar2complex(double[] amps,
• #### polar2complex

```public static ComplexNumber[] polar2complex(double[] amps,

```public static double[] add(double[] x,
double[] y)```

```public static double[] add(double[] a,
double b)```
• #### subtract

```public static double[] subtract(double[] a,
double[] b)```
• #### subtract

```public static double[] subtract(double[] a,
double b)```
• #### multiply

```public static double[] multiply(double[] a,
double[] b)```
• #### multiply

```public static float[] multiply(float[] a,
float[] b)```
• #### multiply

```public static double[] multiply(double[] a,
double b)```
• #### multiply

```public static float[] multiply(float[] a,
float b)```
• #### invert

```public static double[] invert(double[] a)
throws IllegalArgumentException```
Returns the multiplicative inverse (element-wise 1/x) of an array
Parameters:
`a` - array to invert
Returns:
a new array of the same size as a, in which each element is equal to the multiplicative inverse of the corresponding element in a
Throws:
`IllegalArgumentException` - if the array is null
• #### invert

`public static float[] invert(float[] a)`
Parameters:
`a` - a
Returns:
c
`invert(double[])`
• #### multiplyComplex

```public static ComplexNumber[] multiplyComplex(ComplexNumber[] a,
double b)```
• #### complexConjugate

`public static ComplexNumber complexConjugate(ComplexNumber x)`
• #### complexConjugate

```public static ComplexNumber complexConjugate(double xReal,
double xImag)```

```public static ComplexNumber addComplex(ComplexNumber x1,
ComplexNumber x2)```

```public static ComplexNumber addComplex(ComplexNumber x,
double yReal,
double yImag)```

```public static ComplexNumber addComplex(double yReal,
double yImag,
ComplexNumber x)```

```public static ComplexNumber addComplex(double xReal,
double xImag,
double yReal,
double yImag)```
• #### subtractComplex

```public static ComplexNumber subtractComplex(ComplexNumber x1,
ComplexNumber x2)```
• #### subtractComplex

```public static ComplexNumber subtractComplex(ComplexNumber x,
double yReal,
double yImag)```
• #### subtractComplex

```public static ComplexNumber subtractComplex(double yReal,
double yImag,
ComplexNumber x)```
• #### subtractComplex

```public static ComplexNumber subtractComplex(double xReal,
double xImag,
double yReal,
double yImag)```
• #### multiplyComplex

```public static ComplexNumber multiplyComplex(ComplexNumber x1,
ComplexNumber x2)```
• #### multiplyComplex

```public static ComplexNumber multiplyComplex(ComplexNumber x,
double yReal,
double yImag)```
• #### multiplyComplex

```public static ComplexNumber multiplyComplex(double yReal,
double yImag,
ComplexNumber x)```
• #### multiplyComplex

```public static ComplexNumber multiplyComplex(double xReal,
double xImag,
double yReal,
double yImag)```
• #### multiply

```public static ComplexNumber multiply(double x1,
ComplexNumber x2)```
• #### divideComplex

```public static ComplexNumber divideComplex(ComplexNumber x,
double yReal,
double yImag)```
• #### divideComplex

```public static ComplexNumber divideComplex(double yReal,
double yImag,
ComplexNumber x)```
• #### divideComplex

```public static ComplexNumber divideComplex(ComplexNumber x1,
ComplexNumber x2)```
• #### divideComplex

```public static ComplexNumber divideComplex(double xReal,
double xImag,
double yReal,
double yImag)```
• #### divide

```public static ComplexNumber divide(ComplexNumber x1,
double x2)```
• #### divide

```public static ComplexNumber divide(double x1,
ComplexNumber x2)```
• #### magnitudeComplexSquared

`public static double magnitudeComplexSquared(ComplexNumber x)`
• #### magnitudeComplexSquared

```public static double magnitudeComplexSquared(double xReal,
double xImag)```
• #### magnitudeComplex

`public static double magnitudeComplex(ComplexNumber x)`
• #### magnitudeComplex

`public static double[] magnitudeComplex(ComplexNumber[] xs)`
• #### magnitudeComplex

`public static double[] magnitudeComplex(ComplexArray x)`
• #### magnitudeComplex

```public static double magnitudeComplex(double xReal,
double xImag)```

`public static double phaseInRadians(ComplexNumber x)`

`public static float phaseInRadiansFloat(ComplexNumber x)`

```public static double phaseInRadians(double xReal,
double xImag)```

`public static double[] phaseInRadians(ComplexNumber[] xs)`

`public static float[] phaseInRadiansFloat(ComplexNumber[] xs)`

`public static double[] phaseInRadians(ComplexArray x)`
• #### complexNumber

```public static ComplexNumber complexNumber(double r,
double theta)```
• #### divide

```public static double[] divide(double[] a,
double[] b)```
• #### divide

```public static double[] divide(double[] a,
double b)```

```public static double[][] add(double[][] x,
double[][] y)```
• #### subtract

```public static double[][] subtract(double[][] x,
double[][] y)```
• #### multiply

```public static double[][] multiply(double a,
double[][] x)```
• #### divide

```public static double[][] divide(double[][] x,
double a)```
• #### matrixProduct

```public static double[] matrixProduct(double[][] x,
double[] y)```
• #### matrixProduct

```public static double[] matrixProduct(double[][] x,
float[] y)```
• #### matrixProduct

```public static ComplexNumber[] matrixProduct(ComplexNumber[][] x,
ComplexNumber[] y)```
• #### matrixProduct

```public static ComplexNumber[] matrixProduct(ComplexNumber[][] x,
double[] y)```
• #### matrixProduct

```public static double[][] matrixProduct(double[] x,
double[][] y)```
• #### matrixProduct

```public static ComplexNumber[][] matrixProduct(ComplexNumber[] x,
ComplexNumber[][] y)```
• #### matrixProduct

```public static double[][] matrixProduct(double[][] x,
double[][] y)```
• #### matrixProduct

```public static ComplexNumber[][] matrixProduct(ComplexNumber[][] x,
ComplexNumber[][] y)```
• #### vectorProduct

```public static double[][] vectorProduct(double[] x,
boolean isColumnVectorX,
double[] y,
boolean isColumnVectorY)```
• #### dotProduct

```public static double dotProduct(double[] x,
double[] y)```
• #### dotProduct

```public static double[][] dotProduct(double[][] x,
double[][] y)```
• #### dbSPL

`public static double dbSPL(double energy)`
Convert energy from linear scale to db SPL scale (comparing energies to the minimum audible energy, one Pascal squared).
Parameters:
`energy` - in time or frequency domain, on a linear energy scale
Returns:
energy on a db scale, or NaN if energy is less than or equal to 0.
• #### dbSPL

`public static double[] dbSPL(double[] energies)`
• #### db

`public static double db(double energy)`
Convert energy from linear scale to db scale.
Parameters:
`energy` - in time or frequency domain, on a linear energy scale
Returns:
energy on a db scale, or NaN if energy is less than or equal to 0.
• #### amp2db

`public static double amp2db(double amp)`
• #### amp2neper

`public static double amp2neper(double amp)`
• #### db

`public static double[] db(double[] energies)`
• #### abs

`public static double[] abs(ComplexArray c)`
• #### abs

`public static double[] abs(ComplexNumber[] x)`
• #### abs

```public static double[] abs(ComplexArray c,
int startInd,
int endInd)```
• #### amp2db

`public static double[] amp2db(double[] amps)`
• #### amp2neper

`public static double[] amp2neper(double[] amps)`
• #### dft2ampdb

`public static double[] dft2ampdb(ComplexArray c)`
• #### dft2ampdb

```public static double[] dft2ampdb(ComplexArray c,
int startInd,
int endInd)```
• #### db2linear

`public static double db2linear(double dbEnergy)`
Convert energy from db scale to linear scale.
Parameters:
`dbEnergy` - in time or frequency domain, on a db energy scale
Returns:
energy on a linear scale.
• #### db2linear

`public static double[] db2linear(double[] dbEnergies)`
• #### linear2db

`public static double[] linear2db(double[] linears)`
• #### db2amp

`public static float db2amp(float dbAmplitude)`
• #### db2amp

`public static double db2amp(double dbAmplitude)`
• #### db2amp

`public static float[] db2amp(float[] dbAmplitudes)`
• #### db2amp

`public static double[] db2amp(double[] dbAmplitudes)`

`public static float radian2degrees(float rad)`

`public static double radian2degrees(double rad)`

`public static float degrees2radian(float deg)`

`public static double degrees2radian(double deg)`
• #### sumSquaredError

```public static double sumSquaredError(double[] a,
double[] b)```
Build the sum of the squared difference of all elements with the same index numbers in the arrays. Any NaN values in either a or b are ignored in computing the error.
Parameters:
`a` - a
`b` - a
Returns:
sum
• #### log10

`public static double log10(double x)`
• #### log

`public static double[] log(double[] a)`
• #### log

```public static double[] log(double[] a,
double minimumValue,
double fixedValue)```
• #### log10

`public static double[] log10(double[] a)`
• #### exp10

`public static double exp10(double x)`
• #### exp

`public static double[] exp(double[] a)`
• #### exp10

`public static double[] exp10(double[] a)`

```public static float[] add(float[] a,
float[] b)```

```public static float[] add(float[] a,
float b)```
• #### subtract

```public static float[] subtract(float[] a,
float[] b)```
• #### subtract

```public static float[] subtract(float[] a,
float b)```
• #### euclidianLength

`public static double euclidianLength(float[] a)`
• #### euclidianLength

`public static double euclidianLength(double[] a)`
• #### toPolarCoordinates

```public static void toPolarCoordinates(double[] x,
double[] y)```
Convert a pair of arrays from cartesian (x, y) coordinates to polar (r, phi) coordinates. Phi will be in radians, i.e. a full circle is two pi.
Parameters:
`x` - as input, the x coordinate; as output, the r coordinate;
`y` - as input, the y coordinate; as output, the phi coordinate.
• #### toCartesianCoordinates

```public static void toCartesianCoordinates(double[] r,
double[] phi)```
Convert a pair of arrays from polar (r, phi) coordinates to cartesian (x, y) coordinates. Phi is in radians, i.e. a whole circle is two pi.
Parameters:
`r` - as input, the r coordinate; as output, the x coordinate;
`phi` - as input, the phi coordinate; as output, the y coordinate.
• #### angleToDefaultAngle

`public static double angleToDefaultAngle(double angle)`
For a given angle in radians, return the equivalent angle in the range [-PI, PI].
Parameters:
`angle` - angle
Returns:
(angle + PI) % (-TWOPI) + PI
• #### angleToDefaultAngle

`public static void angleToDefaultAngle(double[] angle)`
For each of an array of angles (in radians), return the equivalent angle in the range [-PI, PI].
Parameters:
`angle` - angle
• #### levinson

```public static double[] levinson(double[] r,
int m)```
This is the Java source code for a Levinson Recursion. from http://www.nauticom.net/www/jdtaft/JavaLevinson.htm
Parameters:
`r` - contains the autocorrelation lags as input [r(0)...r(m)].
`m` - m
Returns:
the array of whitening coefficients
• #### levinson

```public static ComplexNumber[] levinson(ComplexNumber[] r,
ComplexNumber[] c)```
• #### interpolate

```public static float[] interpolate(float[] x,
int newLength)```
• #### interpolate

```public static double[] interpolate(double[] x,
int newLength)```
• #### interpolate

```public static ComplexNumber[] interpolate(ComplexNumber[] x,
int newLength)```
• #### interpolate

```public static double[] interpolate(int[] xInds,
double[] xVals,
int[] xInds2)```
• #### interpolatedSample

```public static double interpolatedSample(double xStart,
double xVal,
double xEnd,
double yStart,
double yEnd)```
• #### getMax

`public static int getMax(int[] x)`
• #### getMinIndex

`public static int getMinIndex(int[] x)`
• #### getMinIndex

```public static int getMinIndex(int[] x,
int startInd)```
• #### getMinIndex

```public static int getMinIndex(int[] x,
int startInd,
int endInd)```
• #### getMaxIndex

`public static int getMaxIndex(int[] x)`
• #### getMaxIndex

```public static int getMaxIndex(int[] x,
int startInd)```
• #### getMaxIndex

```public static int getMaxIndex(int[] x,
int startInd,
int endInd)```
• #### getExtremaIndex

```public static int getExtremaIndex(int[] x,
boolean isMax)```
• #### getExtremaIndex

```public static int getExtremaIndex(int[] x,
boolean isMax,
int startInd)```
• #### getExtremaIndex

```public static int getExtremaIndex(int[] x,
boolean isMax,
int startInd,
int endInd)```
• #### getMinIndex

`public static int getMinIndex(float[] x)`
• #### getMinIndex

```public static int getMinIndex(float[] x,
int startInd)```
• #### getMinIndex

```public static int getMinIndex(float[] x,
int startInd,
int endInd)```
• #### getMaxIndex

`public static int getMaxIndex(float[] x)`
• #### getMaxIndex

```public static int getMaxIndex(float[] x,
int startInd)```
• #### getMaxIndex

```public static int getMaxIndex(float[] x,
int startInd,
int endInd)```
• #### getExtremaIndex

```public static int getExtremaIndex(float[] x,
boolean isMax)```
• #### getExtremaIndex

```public static int getExtremaIndex(float[] x,
boolean isMax,
int startInd)```
• #### getExtremaIndex

```public static int getExtremaIndex(float[] x,
boolean isMax,
int startInd,
int endInd)```
• #### getMinIndex

`public static int getMinIndex(double[] x)`
• #### getMinIndex

```public static int getMinIndex(double[] x,
int startInd)```
• #### getMinIndex

```public static int getMinIndex(double[] x,
int startInd,
int endInd)```
• #### getMaxIndex

`public static int getMaxIndex(double[] x)`
• #### getMaxIndex

```public static int getMaxIndex(double[] x,
int[] inds)```
• #### getMaxIndex

```public static int getMaxIndex(double[] x,
int startInd)```
• #### getMaxIndex

```public static int getMaxIndex(double[] x,
int startInd,
int endInd)```
• #### getExtremaIndex

```public static int getExtremaIndex(double[] x,
boolean isMax)```
• #### getExtremaIndex

```public static int getExtremaIndex(double[] x,
boolean isMax,
int startInd)```
• #### getExtremaIndex

```public static int getExtremaIndex(double[] x,
boolean isMax,
int startInd,
int endInd)```
• #### getMax

`public static double getMax(double[] x)`
• #### getMax

`public static float getMax(float[] x)`
• #### getMin

`public static int getMin(int[] x)`
• #### getMin

`public static double getMin(double[] x)`
• #### getMin

`public static float getMin(float[] x)`
• #### getAbsMax

`public static double getAbsMax(double[] x)`
• #### getAbsMax

```public static double getAbsMax(double[] x,
int startInd,
int endInd)```
• #### getAbsMaxInd

```public static int getAbsMaxInd(double[] x,
int startInd,
int endInd)```
• #### filledArray

```public static double[] filledArray(double val,
int len)```
• #### filledArray

```public static float[] filledArray(float val,
int len)```
• #### filledArray

```public static int[] filledArray(int val,
int len)```
• #### zeros

`public static double[] zeros(int len)`
• #### ones

`public static double[] ones(int len)`
• #### zerosInt

`public static int[] zerosInt(int len)`
• #### onesInt

`public static int[] onesInt(int len)`
• #### zerosFloat

`public static float[] zerosFloat(int len)`
• #### onesFloat

`public static float[] onesFloat(int len)`
• #### find

```public static int[] find(int[] x,
int comparator,
int val)```
• #### findAnd

```public static int[] findAnd(int[] x,
int comparator1,
int val1,
int comparator2,
int val2)```
• #### findOr

```public static int[] findOr(int[] x,
int comparator1,
int val1,
int comparator2,
int val2)```
• #### findAnd

```public static int[] findAnd(double[] x,
int comparator1,
double val1,
int comparator2,
double val2)```
• #### findOr

```public static int[] findOr(double[] x,
int comparator1,
double val1,
int comparator2,
double val2)```
• #### findValues

```public static double[] findValues(double[] x,
int comparator,
double val)```
• #### find

```public static int[] find(double[] x,
int comparator,
double val)```
• #### interpolate_linear

```public static double[] interpolate_linear(int[] x,
double[] y,
int[] xi)```
• #### CheckLimits

```public static int CheckLimits(int val,
int minVal,
int maxVal)```
• #### CheckLimits

```public static double CheckLimits(double val,
double minVal,
double maxVal)```
• #### CheckLimits

```public static float CheckLimits(float val,
float minVal,
float maxVal)```
• #### getExtrema

```public static int[] getExtrema(double[] x,
int numLeftN,
int numRightN,
boolean isMaxima)```
• #### getExtrema

```public static int[] getExtrema(double[] x,
int numLeftN,
int numRightN,
boolean isMaxima,
int startInd)```
• #### getExtrema

```public static int[] getExtrema(double[] x,
int numLeftN,
int numRightN,
boolean isMaxima,
int startInd,
int endInd)```
• #### getExtrema

```public static int[] getExtrema(double[] x,
int numLeftN,
int numRightN,
boolean isMaxima,
int startInd,
int endInd,
double th)```
• #### getExtrema

```public static int[] getExtrema(double[] x,
int[] numLeftNs,
int[] numRightNs,
boolean isMaxima)```
• #### getExtrema

```public static int[] getExtrema(double[] x,
int[] numLeftNs,
int[] numRightNs,
boolean isMaxima,
int startInd)```
• #### getExtrema

```public static int[] getExtrema(double[] x,
int[] numLeftNs,
int[] numRightNs,
boolean isMaxima,
int startInd,
int endInd)```
• #### getExtrema

```public static int[] getExtrema(double[] x,
int[] numLeftNs,
int[] numRightNs,
boolean isMaxima,
int startInd,
int endInd,
double th)```
• #### getRandoms

`public static double[] getRandoms(int len)`
• #### getRandoms

```public static double[] getRandoms(int len,
double minVal,
double maxVal)```
• #### findClosest

```public static int findClosest(float[] x,
float val)```
• #### findClosest

```public static int findClosest(int[] x,
int val)```
• #### unwrap

```public static float unwrap(float phaseInRadians,
• #### unwrapToRange

```public static float unwrapToRange(float phaseInDegrees,
float lowestDegree)```
• #### db2neper

`public static double db2neper(double db)`
• #### db2neper

`public static double[] db2neper(double[] dbs)`
• #### neper2db

`public static double neper2db(double neper)`
• #### neper2db

`public static double[] neper2db(double[] nepers)`
• #### neper2linear

`public static double neper2linear(double neper)`
• #### neper2linear

`public static double[] neper2linear(double[] nepers)`
• #### sinc

```public static float[] sinc(float[] x,
float N)```
• #### sinc

```public static float sinc(float x,
float N)```
• #### sinc

```public static double sinc(double x,
double N)```
• #### sinc

`public static float[] sinc(float[] x)`
• #### sinc

`public static double[] sinc(double[] x)`
• #### sinc

`public static float sinc(float x)`
• #### sinc

`public static double sinc(double x)`
• #### getSortedValue

```public static double getSortedValue(double[] x,
double percentSmallerThan)```
• #### factorialDesign

`public static int[][] factorialDesign(int[] totalItemsInNodes)`
• #### linearMap

```public static float linearMap(float x,
float xStart,
float xEnd,
float yStart,
float yEnd)```
• #### linearMap

```public static double linearMap(double x,
double xStart,
double xEnd,
double yStart,
double yEnd)```
• #### linearMap

```public static int linearMap(int x,
int xStart,
int xEnd,
int yStart,
int yEnd)```
• #### quickSort

`public static int[] quickSort(int[] x)`
• #### quickSort

`public static int[] quickSort(double[] x)`
• #### quickSort

`public static int[] quickSort(float[] x)`
• #### quickSort

```public static int[] quickSort(double[] x,
int startIndex,
int endIndex)```
• #### quickSort

```public static int[] quickSort(float[] x,
int startIndex,
int endIndex)```
• #### quickSort

```public static void quickSort(double[] x,
int[] y)```
• #### quickSort

```public static void quickSort(float[] x,
int[] y)```
• #### quickSort

```public static void quickSort(double[] x,
int[] y,
int startIndex,
int endIndex)```
• #### quickSort

```public static void quickSort(float[] x,
int[] y,
int startIndex,
int endIndex)```
• #### sortAs

```public static double[] sortAs(double[] x,
int[] sortedIndices)```
• #### sortAs

```public static float[] sortAs(float[] x,
int[] sortedIndices)```
• #### normalizeZscore

`public static double[] normalizeZscore(double[] x)`
Calculates x_i = (x_i - mean(x)) / std(x) This function can deal with NaNs
Parameters:
`x` - x
Returns:
x
• #### normalizeToSumUpTo

```public static double[] normalizeToSumUpTo(double[] x,
double sumUp)```
• #### normalizeToSumUpTo

```public static double[] normalizeToSumUpTo(double[] x,
int len,
double sumUp)```
• #### normalizeToRange

```public static double[] normalizeToRange(double[] x,
int len,
double minVal,
double maxVal)```
• #### normalizeToAbsMax

```public static double[] normalizeToAbsMax(double[] x,
double absMax)```

```public static void adjustMean(double[] x,
double newMean)```

```public static void adjustVariance(double[] x,
double newVariance)```

```public static void adjustMeanVariance(double[] x,
double newMean,
double newVariance)```

```public static void adjustVariance(double[] x,
double newVariance,
double currentMean)```

```public static void adjustMeanStandardDeviation(double[] x,
double newMean,
double newStandardDeviation)```

```public static void adjustStandardDeviation(double[] x,
double newStandardDeviation)```

```public static void adjustStandardDeviation(double[] x,
double newStandardDeviation,
double currentMean)```

```public static void adjustMeanStandardDeviation(double[] x,
double currentMean,
double newMean,
double newStandardDeviation)```

```public static void adjustRange(double[] x,
double minVal,
double maxVal)```
• #### clipRange

```public static boolean clipRange(double[] x,
double minVal,
double maxVal)```
Adjust values in x so that all values smaller than minVal are set to minVal, and all values greater than maxVal are set to maxVal
Parameters:
`x` - array of doubles to adjust; if x is null, nothing happens
`minVal` - minimum of all values in x after adjustment
`maxVal` - maximum of all values in x after adjustment
Returns:
true if one or more values in x were modified, false if x is unchanged
• #### median

`public static double median(double[] x)`
• #### median

```public static double median(double[] xin,
int firstIndex,
int lastIndex)```
• #### absMean

`public static double absMean(double[] x)`
• #### getVarianceRows

`public static double[] getVarianceRows(double[][] x)`
• #### getVarianceCols

`public static double[] getVarianceCols(double[][] x)`
• #### getGaussianPdfValueConstantTerm

```public static double getGaussianPdfValueConstantTerm(int featureDimension,
double detCovarianceMatrix)```
• #### getGaussianPdfValueConstantTermLog

```public static double getGaussianPdfValueConstantTermLog(int featureDimension,
double detCovarianceMatrix)```
• #### getGaussianPdfValue

```public static double getGaussianPdfValue(double[] x,
double[] meanVector,
double[] covarianceMatrix)```
• #### getGaussianPdfValue

```public static double getGaussianPdfValue(double[] x,
double[] meanVector,
double[] covarianceMatrix,
double constantTerm)```
• #### getGaussianPdfValueLog

```public static double getGaussianPdfValueLog(double[] x,
double[] meanVector,
double[] covarianceMatrix,
double constantTermLog)```
• #### getGaussianPdfValue

```public static double getGaussianPdfValue(double[] x,
double[] meanVector,
double detCovarianceMatrix,
double[][] inverseCovarianceMatrix)```
• #### getGaussianPdfValue

```public static double getGaussianPdfValue(double[] x,
double[] meanVector,
double[][] inverseCovarianceMatrix,
double constantTerm)```
• #### determinant

`public static double determinant(double[] diagonal)`
• #### determinant

`public static double determinant(double[][] matrix)`
• #### random

`public static double[] random(int numSamples)`
• #### random

```public static double[] random(int numSamples,
double minVal,
double maxVal)```
• #### inverse

`public static double[] inverse(double[] x)`
• #### inverse

`public static ComplexNumber[] inverse(ComplexNumber[] x)`
• #### inverse

`public static double[][] inverse(double[][] matrix)`
• #### inverse

`public static ComplexNumber[][] inverse(ComplexNumber[][] matrix)`
• #### inverseInPlace

`public static void inverseInPlace(double[][] matrix)`
• #### inverseInPlace

`public static void inverseInPlace(ComplexNumber[][] matrix)`
• #### luDecompose

```public static void luDecompose(double[][] a,
int n,
int[] indx,
double[] d)```
• #### luDecompose

```public static void luDecompose(ComplexNumber[][] a,
int n,
int[] indx,
ComplexNumber[] d)```
• #### luSubstitute

```public static void luSubstitute(double[][] a,
int[] indx,
double[] b)```
• #### luSubstitute

```public static void luSubstitute(ComplexNumber[][] a,
int[] indx,
ComplexNumber[] b)```

```public static double logAdd(double x,
double y)```
• #### getLargestIndexSmallerThan

```public static int getLargestIndexSmallerThan(double[] x,
double val)```
• #### randomSort

`public static int[] randomSort(int[] x)`
• #### randomSort

`public static double[][] randomSort(double[][] x)`

```public static int[] addIndex(int[] X,
int x)```
Add val x to list of int X
Parameters:
`X` - X
`x` - x
Returns:
newX
• #### removeIndex

```public static int[] removeIndex(int[] X,
int x)```
Remove val x from list of int X
Parameters:
`X` - X
`x` - x
Returns:
newX
• #### modifySize

```public static double[] modifySize(double[] x,
int newLen)```
• #### getConfidenceInterval95

`public static double getConfidenceInterval95(double standardDeviation)`
• #### getConfidenceInterval99

`public static double getConfidenceInterval99(double standardDeviation)`
• #### autocorr

```public static double[] autocorr(double[] x,
int P)```
• #### isAnyNaN

`public static boolean isAnyNaN(double[] x)`
• #### isAnyInfinity

`public static boolean isAnyInfinity(double[] x)`
Check whether x contains Infinity
Parameters:
`x` - the array to check
Returns:
true if at least one value in x is Infinity, false otherwise
• #### allZeros

`public static boolean allZeros(double[] x)`
• #### doubleRange2ByteRange

`public static double[] doubleRange2ByteRange(double[] x)`
• #### doubleRange2ByteRange

```public static double[] doubleRange2ByteRange(double[] x,
double doubleMin,
double doubleMax)```
• #### byteRange2DoubleRange

`public static double[] byteRange2DoubleRange(double[] x)`
• #### byteRange2DoubleRange

```public static double[] byteRange2DoubleRange(double[] x,
double doubleMin,
double doubleMax)```
• #### floatRange2ByteRange

`public static float[] floatRange2ByteRange(float[] x)`
• #### floatRange2ByteRange

```public static float[] floatRange2ByteRange(float[] x,
float floatMin,
float floatMax)```
• #### byteRange2FloatRange

`public static float[] byteRange2FloatRange(float[] x)`
• #### byteRange2FloatRange

```public static float[] byteRange2FloatRange(float[] x,
float floatMin,
float floatMax)```
• #### trimToRange

```public static double trimToRange(double untrimmedValue,
double min,
double max)```
Trim the given value so that it is in the closed interval [min, max].
Parameters:
`untrimmedValue` - untrimmedValue
`min` - min
`max` - max
Returns:
min if untrimmedValue is less than min; max if untrimmedValue is more than max; untrimmedValue otherwise.
• #### interpolateNonZeroValues

`public static double[] interpolateNonZeroValues(double[] contour)`
To interpolate Zero values with respect to NonZero values
Parameters:
`contour` - contour
Returns:
contour
• #### findNextIndexNonZero

```public static int findNextIndexNonZero(double[] contour,
int current)```
To find next NonZero index in a given array
Parameters:
`contour` - contour
`current` - current
Returns:
-1
• #### arrayResize

```public static double[] arrayResize(double[] source,
int targetSize)```
array resize to target size using linear interpolation
Parameters:
`source` - source
`targetSize` - targetSize
Returns:
source if source.length == targetSize, newSignal otherwise
• #### diff

`public static double[] diff(double[] a)`
Get first-order discrete difference along adjacent values in an array
Parameters:
`a` - a
Returns:
array of differences between adjacent values in a, length is `a.length-1`; otherwise return null if a is null, or [] if the length of a is less than 2.
• #### main

`public static void main(String[] args)`
• #### toStringLines

`public static String[] toStringLines(ComplexNumber[] x)`
• #### toStringLines

`public static String[] toStringLines(ComplexArray x)`
• #### toString

`public static String toString(ComplexNumber[][] array)`