public class MathUtils extends Object
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 and Description |
---|
MathUtils() |
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) |
public static final double TINY_PROBABILITY
public static final double TINY_PROBABILITY_LOG
public static final double TINY
public static final double TINY_LOG
protected static final double PASCAL
protected static final double PASCALSQUARE
protected static final double LOG10
public static final double TWOPI
public static final int EQUALS
public static final int GREATER_THAN
public static final int GREATER_THAN_OR_EQUALS
public static final int LESS_THAN
public static final int LESS_THAN_OR_EQUALS
public static final int NOT_EQUALS
public static boolean isPowerOfTwo(int N)
public static int closestPowerOfTwoAbove(int N)
public static int findNextValleyLocation(double[] data, int startIndex)
public static int findNextPeakLocation(double[] data, int startIndex)
public static int findGlobalPeakLocation(double[] data)
data
- datapublic static int findGlobalPeakLocation(float[] data)
data
- datapublic static int findGlobalValleyLocation(double[] data)
data
- datapublic static int findGlobalValleyLocation(float[] data)
data
- datapublic static double sum(double[] data)
data
- datapublic static float sum(float[] data)
public static int sum(int[] data)
public static double sumSquared(double[] data)
public static double sumSquared(double[] data, double term)
public static double sumSquared(double[] data, int startInd, int endInd)
public static double sumSquared(double[] data, int startInd, int endInd, double term)
public static double max(double[] data)
data
- datapublic static int max(int[] data)
public static double absMax(double[] data)
data
- datapublic static double absMax(double[] data, int off, int len)
data
- dataoff
- offlen
- lenpublic static double min(double[] data)
data
- datapublic static int min(int[] data)
public static double mean(double[] data)
public static double mean(double[] data, int startIndex, int endIndex)
data
- datastartIndex
- start indexendIndex
- end indexIllegalArgumentException
- if the array contains NaN values.public static double mean(double[] data, int[] inds)
data
- datainds
- indsIllegalArgumentException
- if the array contains NaN values.public static float mean(float[] data, int startIndex, int endIndex)
data
- datastartIndex
- start indexendIndex
- end indexIllegalArgumentException
- if the array contains NaN values.public static float mean(float[] data)
public static float mean(float[] data, int[] inds)
data
- datainds
- indsIllegalArgumentException
- if the array contains NaN values.public static double mean(double[] data, int opt)
data
- double[]opt
- 0: arithmetic mean, 1: geometric meanpublic static double standardDeviation(double[] data)
public static double standardDeviation(double[] data, double meanVal)
public static double standardDeviation(double[] data, double meanVal, int startIndex, int endIndex)
public static double standardDeviation(double[] data, int opt)
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 meanpublic static double variance(double[] data, int opt)
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 meanpublic static double variance(double[] data)
public static float variance(float[] data)
public static double variance(double[] data, double meanVal)
public static float variance(float[] data, float meanVal)
public static float variance(float[] data, float meanVal, int startIndex, int endIndex)
public static double variance(double[] data, double meanVal, int startIndex, int endIndex)
public static double[] variance(double[][] x, double[] meanVector)
public static double[] variance(double[][] x, double[] meanVector, boolean isAlongRows)
x
- the matrix consisting of row vectorsmeanVector
- 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
- isAlongRowspublic static double[] mean(double[][] x)
public static double[] mean(double[][] x, boolean isAlongRows)
public static double[] mean(double[][] x, boolean isAlongRows, int[] indicesOfX)
public static double[][] covariance(double[][] x)
public static double[][] covariance(double[][] x, double[] meanVector)
public static double[][] covariance(double[][] x, boolean isAlongRows)
public static double[][] covariance(double[][] x, double[] meanVector, boolean isAlongRows)
public static double[][] covariance(double[][] x, double[] meanVector, boolean isAlongRows, int[] indicesOfX)
public static double correlation(double[] x, double[] y)
x
- xy
- ypublic static double[] diagonal(double[][] x)
public static double[][] toDiagonalMatrix(double[] x)
public static double[][] transpoze(double[] x)
public static double[][] transpoze(double[][] x)
public static ComplexNumber[][] transpoze(ComplexNumber[][] x)
public static ComplexNumber[][] hermitianTranspoze(ComplexNumber[][] x)
public static ComplexNumber[][] diagonalComplexMatrix(double[] diag)
public static double[][] diagonalMatrix(double[] diag)
public static ComplexNumber ampPhase2ComplexNumber(double amp, double phaseInRadians)
public static ComplexNumber[] polar2complex(double[] amps, float[] phasesInRadian)
public static ComplexNumber[] polar2complex(double[] amps, double[] phasesInRadian)
public static double[] add(double[] x, double[] y)
public static double[] add(double[] a, double b)
public static double[] subtract(double[] a, double[] b)
public static double[] subtract(double[] a, double b)
public static double[] multiply(double[] a, double[] b)
public static float[] multiply(float[] a, float[] b)
public static double[] multiply(double[] a, double b)
public static float[] multiply(float[] a, float b)
public static double[] invert(double[] a) throws IllegalArgumentException
a
- array to invertIllegalArgumentException
- if the array is nullpublic static float[] invert(float[] a)
a
- ainvert(double[])
public static ComplexNumber[] multiplyComplex(ComplexNumber[] a, double b)
public static ComplexNumber complexConjugate(ComplexNumber x)
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)
public static ComplexNumber subtractComplex(ComplexNumber x1, ComplexNumber x2)
public static ComplexNumber subtractComplex(ComplexNumber x, double yReal, double yImag)
public static ComplexNumber subtractComplex(double yReal, double yImag, ComplexNumber x)
public static ComplexNumber subtractComplex(double xReal, double xImag, double yReal, double yImag)
public static ComplexNumber multiplyComplex(ComplexNumber x1, ComplexNumber x2)
public static ComplexNumber multiplyComplex(ComplexNumber x, double yReal, double yImag)
public static ComplexNumber multiplyComplex(double yReal, double yImag, ComplexNumber x)
public static ComplexNumber multiplyComplex(double xReal, double xImag, double yReal, double yImag)
public static ComplexNumber multiply(double x1, ComplexNumber x2)
public static ComplexNumber divideComplex(ComplexNumber x, double yReal, double yImag)
public static ComplexNumber divideComplex(double yReal, double yImag, ComplexNumber x)
public static ComplexNumber divideComplex(ComplexNumber x1, ComplexNumber x2)
public static ComplexNumber divideComplex(double xReal, double xImag, double yReal, double yImag)
public static ComplexNumber divide(ComplexNumber x1, double x2)
public static ComplexNumber divide(double x1, ComplexNumber x2)
public static double magnitudeComplexSquared(ComplexNumber x)
public static double magnitudeComplexSquared(double xReal, double xImag)
public static double magnitudeComplex(ComplexNumber x)
public static double[] magnitudeComplex(ComplexNumber[] xs)
public static double[] magnitudeComplex(ComplexArray x)
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)
public static ComplexNumber complexNumber(double r, double theta)
public static double[] divide(double[] a, double[] b)
public static double[] divide(double[] a, double b)
public static double[][] add(double[][] x, double[][] y)
public static double[][] subtract(double[][] x, double[][] y)
public static double[][] multiply(double a, double[][] x)
public static double[][] divide(double[][] x, double a)
public static double[] matrixProduct(double[][] x, double[] y)
public static double[] matrixProduct(double[][] x, float[] y)
public static ComplexNumber[] matrixProduct(ComplexNumber[][] x, ComplexNumber[] y)
public static ComplexNumber[] matrixProduct(ComplexNumber[][] x, double[] y)
public static double[][] matrixProduct(double[] x, double[][] y)
public static ComplexNumber[][] matrixProduct(ComplexNumber[] x, ComplexNumber[][] y)
public static double[][] matrixProduct(double[][] x, double[][] y)
public static ComplexNumber[][] matrixProduct(ComplexNumber[][] x, ComplexNumber[][] y)
public static double[][] vectorProduct(double[] x, boolean isColumnVectorX, double[] y, boolean isColumnVectorY)
public static double dotProduct(double[] x, double[] y)
public static double[][] dotProduct(double[][] x, double[][] y)
public static double dbSPL(double energy)
energy
- in time or frequency domain, on a linear energy scalepublic static double[] dbSPL(double[] energies)
public static double db(double energy)
energy
- in time or frequency domain, on a linear energy scalepublic static double amp2db(double amp)
public static double amp2neper(double amp)
public static double[] db(double[] energies)
public static double[] abs(ComplexArray c)
public static double[] abs(ComplexNumber[] x)
public static double[] abs(ComplexArray c, int startInd, int endInd)
public static double[] amp2db(double[] amps)
public static double[] amp2neper(double[] amps)
public static double[] dft2ampdb(ComplexArray c)
public static double[] dft2ampdb(ComplexArray c, int startInd, int endInd)
public static double db2linear(double dbEnergy)
dbEnergy
- in time or frequency domain, on a db energy scalepublic static double[] db2linear(double[] dbEnergies)
public static double[] linear2db(double[] linears)
public static float db2amp(float dbAmplitude)
public static double db2amp(double dbAmplitude)
public static float[] db2amp(float[] dbAmplitudes)
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)
public static double sumSquaredError(double[] a, double[] b)
a
- ab
- apublic static double log10(double x)
public static double[] log(double[] a)
public static double[] log(double[] a, double minimumValue, double fixedValue)
public static double[] log10(double[] a)
public static double exp10(double x)
public static double[] exp(double[] a)
public static double[] exp10(double[] a)
public static float[] add(float[] a, float[] b)
public static float[] add(float[] a, float b)
public static float[] subtract(float[] a, float[] b)
public static float[] subtract(float[] a, float b)
public static double euclidianLength(float[] a)
public static double euclidianLength(double[] a)
public static void toPolarCoordinates(double[] x, double[] y)
x
- as input, the x coordinate; as output, the r coordinate;y
- as input, the y coordinate; as output, the phi coordinate.public static void toCartesianCoordinates(double[] r, double[] phi)
r
- as input, the r coordinate; as output, the x coordinate;phi
- as input, the phi coordinate; as output, the y coordinate.public static double angleToDefaultAngle(double angle)
angle
- anglepublic static void angleToDefaultAngle(double[] angle)
angle
- anglepublic static double[] levinson(double[] r, int m)
r
- contains the autocorrelation lags as input [r(0)...r(m)].m
- mpublic static ComplexNumber[] levinson(ComplexNumber[] r, ComplexNumber[] c)
public static float[] interpolate(float[] x, int newLength)
public static double[] interpolate(double[] x, int newLength)
public static ComplexNumber[] interpolate(ComplexNumber[] x, int newLength)
public static double[] interpolate(int[] xInds, double[] xVals, int[] xInds2)
public static double interpolatedSample(double xStart, double xVal, double xEnd, double yStart, double yEnd)
public static int getMax(int[] x)
public static int getMinIndex(int[] x)
public static int getMinIndex(int[] x, int startInd)
public static int getMinIndex(int[] x, int startInd, int endInd)
public static int getMaxIndex(int[] x)
public static int getMaxIndex(int[] x, int startInd)
public static int getMaxIndex(int[] x, int startInd, int endInd)
public static int getExtremaIndex(int[] x, boolean isMax)
public static int getExtremaIndex(int[] x, boolean isMax, int startInd)
public static int getExtremaIndex(int[] x, boolean isMax, int startInd, int endInd)
public static int getMinIndex(float[] x)
public static int getMinIndex(float[] x, int startInd)
public static int getMinIndex(float[] x, int startInd, int endInd)
public static int getMaxIndex(float[] x)
public static int getMaxIndex(float[] x, int startInd)
public static int getMaxIndex(float[] x, int startInd, int endInd)
public static int getExtremaIndex(float[] x, boolean isMax)
public static int getExtremaIndex(float[] x, boolean isMax, int startInd)
public static int getExtremaIndex(float[] x, boolean isMax, int startInd, int endInd)
public static int getMinIndex(double[] x)
public static int getMinIndex(double[] x, int startInd)
public static int getMinIndex(double[] x, int startInd, int endInd)
public static int getMaxIndex(double[] x)
public static int getMaxIndex(double[] x, int[] inds)
public static int getMaxIndex(double[] x, int startInd)
public static int getMaxIndex(double[] x, int startInd, int endInd)
public static int getExtremaIndex(double[] x, boolean isMax)
public static int getExtremaIndex(double[] x, boolean isMax, int startInd)
public static int getExtremaIndex(double[] x, boolean isMax, int startInd, int endInd)
public static double getMax(double[] x)
public static float getMax(float[] x)
public static int getMin(int[] x)
public static double getMin(double[] x)
public static float getMin(float[] x)
public static double getAbsMax(double[] x)
public static double getAbsMax(double[] x, int startInd, int endInd)
public static int getAbsMaxInd(double[] x, int startInd, int endInd)
public static double[] filledArray(double val, int len)
public static float[] filledArray(float val, int len)
public static int[] filledArray(int val, int len)
public static double[] zeros(int len)
public static double[] ones(int len)
public static int[] zerosInt(int len)
public static int[] onesInt(int len)
public static float[] zerosFloat(int len)
public static float[] onesFloat(int len)
public static int[] find(int[] x, int comparator, int val)
public static int[] findAnd(int[] x, int comparator1, int val1, int comparator2, int val2)
public static int[] findOr(int[] x, int comparator1, int val1, int comparator2, int val2)
public static int[] findAnd(double[] x, int comparator1, double val1, int comparator2, double val2)
public static int[] findOr(double[] x, int comparator1, double val1, int comparator2, double val2)
public static double[] findValues(double[] x, int comparator, double val)
public static int[] find(double[] x, int comparator, double val)
public static double[] interpolate_linear(int[] x, double[] y, int[] xi)
public static int CheckLimits(int val, int minVal, int maxVal)
public static double CheckLimits(double val, double minVal, double maxVal)
public static float CheckLimits(float val, float minVal, float maxVal)
public static int[] getExtrema(double[] x, int numLeftN, int numRightN, boolean isMaxima)
public static int[] getExtrema(double[] x, int numLeftN, int numRightN, boolean isMaxima, int startInd)
public static int[] getExtrema(double[] x, int numLeftN, int numRightN, boolean isMaxima, int startInd, int endInd)
public static int[] getExtrema(double[] x, int numLeftN, int numRightN, boolean isMaxima, int startInd, int endInd, double th)
public static int[] getExtrema(double[] x, int[] numLeftNs, int[] numRightNs, boolean isMaxima)
public static int[] getExtrema(double[] x, int[] numLeftNs, int[] numRightNs, boolean isMaxima, int startInd)
public static int[] getExtrema(double[] x, int[] numLeftNs, int[] numRightNs, boolean isMaxima, int startInd, int endInd)
public static int[] getExtrema(double[] x, int[] numLeftNs, int[] numRightNs, boolean isMaxima, int startInd, int endInd, double th)
public static double[] getRandoms(int len)
public static double[] getRandoms(int len, double minVal, double maxVal)
public static int findClosest(float[] x, float val)
public static int findClosest(int[] x, int val)
public static float unwrap(float phaseInRadians, float prevPhaseInRadians)
public static float unwrapToRange(float phaseInDegrees, float lowestDegree)
public static double db2neper(double db)
public static double[] db2neper(double[] dbs)
public static double neper2db(double neper)
public static double[] neper2db(double[] nepers)
public static double neper2linear(double neper)
public static double[] neper2linear(double[] nepers)
public static float[] sinc(float[] x, float N)
public static float sinc(float x, float N)
public static double sinc(double x, double N)
public static float[] sinc(float[] x)
public static double[] sinc(double[] x)
public static float sinc(float x)
public static double sinc(double x)
public static double getSortedValue(double[] x, double percentSmallerThan)
public static int[][] factorialDesign(int[] totalItemsInNodes)
public static float linearMap(float x, float xStart, float xEnd, float yStart, float yEnd)
public static double linearMap(double x, double xStart, double xEnd, double yStart, double yEnd)
public static int linearMap(int x, int xStart, int xEnd, int yStart, int yEnd)
public static int[] quickSort(int[] x)
public static int[] quickSort(double[] x)
public static int[] quickSort(float[] x)
public static int[] quickSort(double[] x, int startIndex, int endIndex)
public static int[] quickSort(float[] x, int startIndex, int endIndex)
public static void quickSort(double[] x, int[] y)
public static void quickSort(float[] x, int[] y)
public static void quickSort(double[] x, int[] y, int startIndex, int endIndex)
public static void quickSort(float[] x, int[] y, int startIndex, int endIndex)
public static double[] sortAs(double[] x, int[] sortedIndices)
public static float[] sortAs(float[] x, int[] sortedIndices)
public static double[] normalizeZscore(double[] x)
x
- xpublic static double[] normalizeToSumUpTo(double[] x, double sumUp)
public static double[] normalizeToSumUpTo(double[] x, int len, double sumUp)
public static double[] normalizeToRange(double[] x, int len, double minVal, double maxVal)
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)
public static boolean clipRange(double[] x, double minVal, double maxVal)
x
- array of doubles to adjust; if x is null, nothing happensminVal
- minimum of all values in x after adjustmentmaxVal
- maximum of all values in x after adjustmentpublic static double median(double[] x)
public static double median(double[] xin, int firstIndex, int lastIndex)
public static double absMean(double[] x)
public static double[] getVarianceRows(double[][] x)
public static double[] getVarianceCols(double[][] x)
public static double getGaussianPdfValueConstantTerm(int featureDimension, double detCovarianceMatrix)
public static double getGaussianPdfValueConstantTermLog(int featureDimension, double detCovarianceMatrix)
public static double getGaussianPdfValue(double[] x, double[] meanVector, double[] covarianceMatrix)
public static double getGaussianPdfValue(double[] x, double[] meanVector, double[] covarianceMatrix, double constantTerm)
public static double getGaussianPdfValueLog(double[] x, double[] meanVector, double[] covarianceMatrix, double constantTermLog)
public static double getGaussianPdfValue(double[] x, double[] meanVector, double detCovarianceMatrix, double[][] inverseCovarianceMatrix)
public static double getGaussianPdfValue(double[] x, double[] meanVector, double[][] inverseCovarianceMatrix, double constantTerm)
public static double determinant(double[] diagonal)
public static double determinant(double[][] matrix)
public static double[] random(int numSamples)
public static double[] random(int numSamples, double minVal, double maxVal)
public static double[] inverse(double[] x)
public static ComplexNumber[] inverse(ComplexNumber[] x)
public static double[][] inverse(double[][] matrix)
public static ComplexNumber[][] inverse(ComplexNumber[][] matrix)
public static void inverseInPlace(double[][] matrix)
public static void inverseInPlace(ComplexNumber[][] matrix)
public static void luDecompose(double[][] a, int n, int[] indx, double[] d)
public static void luDecompose(ComplexNumber[][] a, int n, int[] indx, ComplexNumber[] d)
public static void luSubstitute(double[][] a, int[] indx, double[] b)
public static void luSubstitute(ComplexNumber[][] a, int[] indx, ComplexNumber[] b)
public static double logAdd(double x, double y)
public static int getLargestIndexSmallerThan(double[] x, double val)
public static int[] randomSort(int[] x)
public static double[][] randomSort(double[][] x)
public static int[] addIndex(int[] X, int x)
X
- Xx
- xpublic static int[] removeIndex(int[] X, int x)
X
- Xx
- xpublic static double[] modifySize(double[] x, int newLen)
public static double getConfidenceInterval95(double standardDeviation)
public static double getConfidenceInterval99(double standardDeviation)
public static double[] autocorr(double[] x, int P)
public static boolean isAnyNaN(double[] x)
public static boolean isAnyInfinity(double[] x)
x
- the array to checkpublic static boolean allZeros(double[] x)
public static double[] doubleRange2ByteRange(double[] x)
public static double[] doubleRange2ByteRange(double[] x, double doubleMin, double doubleMax)
public static double[] byteRange2DoubleRange(double[] x)
public static double[] byteRange2DoubleRange(double[] x, double doubleMin, double doubleMax)
public static float[] floatRange2ByteRange(float[] x)
public static float[] floatRange2ByteRange(float[] x, float floatMin, float floatMax)
public static float[] byteRange2FloatRange(float[] x)
public static float[] byteRange2FloatRange(float[] x, float floatMin, float floatMax)
public static double trimToRange(double untrimmedValue, double min, double max)
untrimmedValue
- untrimmedValuemin
- minmax
- maxpublic static double[] interpolateNonZeroValues(double[] contour)
contour
- contourpublic static int findNextIndexNonZero(double[] contour, int current)
contour
- contourcurrent
- currentpublic static double[] arrayResize(double[] source, int targetSize)
source
- sourcetargetSize
- targetSizepublic static double[] diff(double[] a)
a
- aa.length-1
; otherwise return null
if a is null, or [] if the length of a is less than 2.public static void main(String[] args)
public static String[] toStringLines(ComplexNumber[] x)
public static String[] toStringLines(ComplexArray x)
public static String toString(ComplexNumber[][] array)
Copyright © 2000–2016 DFKI GmbH. All rights reserved.