com.jstatcom.util
Class UMatrix
- java.lang.Object
-
- com.jstatcom.util.UMatrix
-
public final class UMatrix extends java.lang.ObjectA collection of static methods that are related to arrays of numbers. This set of methods contains mainly general array manipulation routines as well as some light-weight mathematical functions.All methods implemented do not modify the original input. Results are always newly created arrays. If the input is somehow wrong an appropriate exception is thrown. All methods require that the input arrays have the same number of elements in each row.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static double[][]add(double[][] arg, double toAdd)Adds the scalartoAddto a copy of the arrayarg.static double[][]appendDoubleCols(double[][] orig, double[][] toAppend)AppendstoAppendto the columns oforigand returns the new merged array.static double[][]appendDoubleRows(double[][] orig, double[][] toAppend)AppendstoAppendto the rows oforigand returns the new merged array.static voidcheckRowLengths(double[][] arg)Checks whether all rows ofarghave the same number of columns.static voidcheckRowLengths(int[][] arg)Checks whether all rows ofarghave the same number of columns.static double[][]cloneDoubleArray(double[][] x)Gets an identical copy ofx.static int[][]cloneIntArray(int[][] x)Gets an identical copy ofx.static booleancompareDoubleArrays(double[][] arg1, double[][] arg2)Compares two double arrays and returnstrue.static booleancompareIntArrays(int[][] arg1, int[][] arg2)Compares two int arrays and returnstrue.static double[]conv(double[] x, double[] z, int start, int end)Computes the discrete convolution function for the vectorsxandzfromstarttoend.static double[][]delCol(double[][] arg, int colIndex)Deletes the colcolIndexfromarg.static double[][]delColsIf(double[][] arg, int... index)Deletes columns ofargthat have been selected byindexand returns a new array with the remaining columns.static double[][]delRow(double[][] arg, int rowIndex)Deletes the rowrowIndexfromarg.static double[][]delRowsIf(double[][] arg, int... index)Deletes rows ofargthat have been selected byindexand returns a new array with the remaining rows.static double[][]eye(int dim)Gets an identity matrix of dimensiondim.static int[]flipIndex(int... arg)Gets a new array with all zero elements ofargset to one and all nonzero elements set to zero.static java.lang.Stringformat(double[][] arg)Gets a string that contains a printed version ofarg.static double[]fracdiff(double[] y, double d)Implementation of the fractional difference operator, see
J.static double[]getDoubleCol(double[][] arg, int colIndex)Gets the column of the arrayargspecified withcolIndex.static double[][]getDoubleCols(double[][] arg, int startCol, int endCol)Gets all columns of the arrayargdefined bystartCol:endCol.static double[]getDoubleRow(double[][] arg, int rowIndex)Gets the row of the arrayargspecified withrowIndex.static double[][]getDoubleRows(double[][] arg, int startRow, int endRow)Gets all rows of the arrayargdefined bystartRow:endRow.static intgetFirstNonzeroIndex(double[] arg)Gets the index of the first nonzero element inarg.static intgetLastNonzeroIndex(double[] arg)Gets the index of the last nonzero element inarg.static intgetNonzeroDoubleCount(double[] arg)Gets the number of nonzero elements inarg.static intgetNonzeroIntCount(int[] arg)Gets the number of nonzero elements inarg.static double[][]lowerTringular(double value, int dim)Gets a quadratic double array of dimensiondimwith all elements on and below the diagonal set tovalue.static double[]maxc(double[][] arg)Gets a vector with the maxima of all columns ofarg.static double[]meanc(double[][] arg)Gets a vector with the mean of all columns ofarg.static double[]minc(double[][] arg)Gets a vector with the minima of all columns ofarg.static double[][]missings(int r, int c)Gets a double array filled with NaN's.static double[][]multiply(double[][] arg, double toMult)Multiplies the scalartoMultwith a copy of the arrayarg.static double[][]ones(int r, int c)Gets a double array filled with 1's.static double[][]pow(double[][] arg, double power)AppliesMath.pow(arg[i][j], power)to all elements ofarg.static intrank(double[][] arg)Get the rank ofarg.static double[][]rndu(int r, int c)Gets a double array filled with random numbers generated byMath.random().static double[][]selColsIf(double[][] arg, int... index)Gets all columns of the arrayargthat have a nonzero corresponding element inindex.static double[][]selRowsIf(double[][] arg, int... index)Gets all rows of the arrayargthat have a nonzero corresponding element inindex.static double[]seqa(double start, double increment, int n)Gets an array with the sequence of numbers starting fromstartbeingn - 1times incremented byincrement.static double[][]standardize(double[][] arg)Gets a new array with the elements ofargdivided by the standard devitation of the respective columns ofarg.static double[]stdc(double[][] arg)Gets a vector with the standard deviations of all columns ofarg.static double[]sumc(double[][] arg)Gets a vector with the sum of all elements in the single columns ofarg.static double[][]toDoubleMatrix(double[] arg)Transforms a one-dimensional array into a K x 1 pseudo-two-dimensional array.static double[][]toDoubleMatrix(int[] arg)Transforms a one-dimensional array into a K x 1 pseudo-two-dimensional array.static double[][]toDoubleMatrix(int[][] arg)Transforms anintarray into adoublearray.static int[][]toIntMatrix(double[][] arg)Transformsarginto an int array by applying a cast to int from double to each element ofarg.static double[][]transpose(double[][] arg)Gets a new array which is the transposearg, which means that all columns ofargare now the rows of the new array.static double[]vec(double[][] arg)Get a one dimensional array with to columns ofargstacked into it.static int[]vec(int[][] arg)Get a one dimensional array with to columns ofargstacked into it.
-
-
-
Method Detail
-
add
public static double[][] add(double[][] arg, double toAdd)Adds the scalartoAddto a copy of the arrayarg.- Parameters:
arg- the original arraytoAdd- the number to add to all elements ofarg- Returns:
- a new array with
toAddadded; iftoAddisNaN, then the resulting array will contain onlyNaN's - Throws:
java.lang.IllegalArgumentException-if (arg == null)or if rows of argument have different lengths
-
appendDoubleCols
public static double[][] appendDoubleCols(double[][] orig, double[][] toAppend)AppendstoAppendto the columns oforigand returns the new merged array. This only works, iforigandtoAppendhave the same number of rows.- Parameters:
orig- the array to append the columns oftoAppendtotoAppend- the arrays to be appended toorig- Returns:
- a new array orig~toAppend
- Throws:
java.lang.IllegalArgumentException-if (orig.length != toAppend.length)orif (orig == null || toAppend == null)or if rows of an argument have different lengths
-
appendDoubleRows
public static double[][] appendDoubleRows(double[][] orig, double[][] toAppend)AppendstoAppendto the rows oforigand returns the new merged array. This only works, iforigandtoAppendhave the same number of columns.- Parameters:
orig- the array to append the rows oftoAppendtotoAppend- the arrays to be appended toorig- Returns:
- a new array orig|toAppend
- Throws:
java.lang.IllegalArgumentException-if (orig[0].length != toAppend[0].length)orif (orig == null || toAppend == null)or if rows of an argument have different lengths
-
checkRowLengths
public static void checkRowLengths(double[][] arg)
Checks whether all rows ofarghave the same number of columns. If the check fails, an exception is thrown. This is to enforce the mathematical definition of a matrix.- Parameters:
arg- thedouble[][]to check- Throws:
java.lang.IllegalArgumentException- if the rows ofarghave different lengths
-
checkRowLengths
public static void checkRowLengths(int[][] arg)
Checks whether all rows ofarghave the same number of columns. If the check fails, an exception is thrown. This is to enforce the mathematical definition of a matrix.- Parameters:
arg- theint[][]to check- Throws:
java.lang.IllegalArgumentException- if the rows ofarghave different lengths
-
cloneDoubleArray
public static double[][] cloneDoubleArray(double[][] x)
Gets an identical copy ofx.- Returns:
- the cloned array or
null if (x == null)-
new double[0][0] if (x.length == 0 || x[0].length == 0)
-
cloneIntArray
public static int[][] cloneIntArray(int[][] x)
Gets an identical copy ofx.- Returns:
- the cloned array or
null if (x == null)-
new int[0][0] if (x.length == 0 || x[0].length == 0)
-
compareDoubleArrays
public static boolean compareDoubleArrays(double[][] arg1, double[][] arg2)Compares two double arrays and returnstrue. if the dimensions are the same and all elements are equal. If two elements ofarg1andarg2areDouble.NaN, they are considered to be equal, whereasarg1, arg2are considered to be unequal if at least one of them isnull.- Parameters:
arg1- double array to comparearg2- double array to compare- Returns:
trueif dimensions and all elements are equal or ifarg1, arg2have both at least one dimension of zero,
falseotherwise- Throws:
java.lang.IllegalArgumentException- if rows of an argument have different lengths
-
compareIntArrays
public static boolean compareIntArrays(int[][] arg1, int[][] arg2)Compares two int arrays and returnstrue. if the dimensions are the same and all elements are equal.- Parameters:
arg1- int array to comparearg2- int array to compare- Returns:
trueif dimensions and all elements are equal or ifarg1, arg2have both at least one dimension of zero,
falseotherwise or if at least one argument isnull- Throws:
java.lang.IllegalArgumentException- if rows of an argument have different lengths
-
delCol
public static double[][] delCol(double[][] arg, int colIndex)Deletes the colcolIndexfromarg.- Parameters:
arg- the array to delete the col fromcolIndex- index of the col- Returns:
- new double array with the deleted col or
new double[0][0]if the array would be empty afterwards - Throws:
java.lang.IllegalArgumentException-if (arg == null)orif (colIndex < 0 || arg[0].length < colIndex)orif (arg.length == 0 || arg[0].length == 0)or if rows of argument have different lengths
-
delColsIf
public static double[][] delColsIf(double[][] arg, int... index)Deletes columns ofargthat have been selected byindexand returns a new array with the remaining columns. A column is selected for deletion if the corresponding index entry is nonzero.- Parameters:
arg- the array to delete columns fromindex- thearg[0].length x 1 intarray- Returns:
- a new array with the selected columns deleted or
new double[0][0]if all columns where selected for deletion or ifarg.length == 0 - Throws:
java.lang.IllegalArgumentException-if (arg == null || index == null)orif ((arg.length == 0 || arg[0].length == 0) && index.length > 0)orif (arg.length == 0 || arg[0].length == 0)or if rows of argument have different lengths
-
delRow
public static double[][] delRow(double[][] arg, int rowIndex)Deletes the rowrowIndexfromarg.- Parameters:
arg- the array to delete the row fromrowIndex- index of the row- Returns:
- new double array with the deleted row or
new double[0][0]if the array would be empty afterwards - Throws:
java.lang.IllegalArgumentException-if (arg == null)orif (rowIndex < 0 || arg.length < rowIndex)orif (arg.length == 0 || arg[0].length == 0)or if rows of argument have different lengths
-
delRowsIf
public static double[][] delRowsIf(double[][] arg, int... index)Deletes rows ofargthat have been selected byindexand returns a new array with the remaining rows. A row is selected for deletion if the corresponding index entry is nonzero.- Parameters:
arg- the array to delete rows fromindex- thearg[0].length x 1 intarray- Returns:
- a new array with the selected rows deleted or
new double[0][0]if all rows where selected for deletion or ifarg.length == 0 - Throws:
java.lang.IllegalArgumentException-if (arg == null || index == null)orif ((arg.length == 0 || arg[0].length == 0) && index.length > 0)orif (arg.length == 0 || arg[0].length == 0)or if rows ofarghave different lengths
-
eye
public static double[][] eye(int dim)
Gets an identity matrix of dimensiondim.- Parameters:
dim- the dimension of the quadratic matrix to create- Returns:
- the created identity matrix
- Throws:
java.lang.IllegalArgumentException-if (dim < 0)
-
flipIndex
public static int[] flipIndex(int... arg)
Gets a new array with all zero elements ofargset to one and all nonzero elements set to zero. Ifargis a selection index then this just reverses the selection.- Parameters:
arg- the original index, usually with 1's and 0's, but any values != 0 are set to 0- Returns:
- the reversed index or
new int[0]ifarg.length == 0 - Throws:
java.lang.IllegalArgumentException-if (arg == null)
-
format
public static java.lang.String format(double[][] arg)
Gets a string that contains a printed version ofarg.- Parameters:
arg- the array to print- Returns:
- a string containing with all elements of
arg - Throws:
java.lang.IllegalArgumentException- if rows of argument have different lengths
-
getDoubleCol
public static double[] getDoubleCol(double[][] arg, int colIndex)Gets the column of the arrayargspecified withcolIndex. The index starts with 0 as usual.- Parameters:
arg- the array to extract a column fromcolIndex- the index of the column to extract (starting from 0)- Returns:
- a one dimensional double array with the column data
- Throws:
java.lang.IllegalArgumentException-if (arg == null)orif (arg.length == 0)or if the index is outside the valid array bounds or if rows of argument have different lengths
-
getDoubleRow
public static double[] getDoubleRow(double[][] arg, int rowIndex)Gets the row of the arrayargspecified withrowIndex. The index starts with 0 as usual.- Parameters:
arg- the array to extract a row fromrowIndex- the index of the row to extract (starting from 0)- Returns:
- a one dimensional double array with the row data
- Throws:
java.lang.IllegalArgumentException-if (arg == null)orif (arg.length == 0)or if the index is outside the valid array bounds or if rows of argument have different lengths
-
getDoubleCols
public static double[][] getDoubleCols(double[][] arg, int startCol, int endCol)Gets all columns of the arrayargdefined bystartCol:endCol. The indices start with 0 as usual.- Parameters:
arg- the array to extract columns fromstartCol- the index of the first column to extract (starting from 0)endCol- the index of the last column to extract (starting from 0)- Returns:
- a two dimensional double array with the column data
- Throws:
java.lang.IllegalArgumentException-if (arg == null)orif (arg.length == 0)orif (startCol > endCol)or if the indices are outside the valid array bounds or if rows of argument have different lengths
-
getDoubleRows
public static double[][] getDoubleRows(double[][] arg, int startRow, int endRow)Gets all rows of the arrayargdefined bystartRow:endRow. The indices start with 0 as usual.- Parameters:
arg- the array to extract rows fromstartRow- the index of the first row to extract (starting from 0)endRow- the index of the last row to extract (starting from 0)- Returns:
- a two dimensional double array with the row data
- Throws:
java.lang.IllegalArgumentException-if (arg == null)orif (arg.length == 0)orif (startRow > endRow)or if the indices are outside the valid array bounds or if rows of argument have different lengths
-
getFirstNonzeroIndex
public static int getFirstNonzeroIndex(double[] arg)
Gets the index of the first nonzero element inarg.- Parameters:
arg- the array to check- Returns:
- the index of the 1st nonzero element or -1 if there is none
- Throws:
java.lang.IllegalArgumentException-if (arg == null)
-
getLastNonzeroIndex
public static int getLastNonzeroIndex(double[] arg)
Gets the index of the last nonzero element inarg.- Parameters:
arg- the array to check- Returns:
- the index of the last nonzero element or -1 if there is none
- Throws:
java.lang.IllegalArgumentException-if (arg == null)
-
getNonzeroDoubleCount
public static int getNonzeroDoubleCount(double[] arg)
Gets the number of nonzero elements inarg.- Parameters:
arg- the array to check- Returns:
- int the number of elements in
argthat are != 0 - Throws:
java.lang.IllegalArgumentException-if (arg == null)
-
getNonzeroIntCount
public static int getNonzeroIntCount(int[] arg)
Gets the number of nonzero elements inarg.- Parameters:
arg- the array to check, usually an index- Returns:
- the number of elements in
argthat are != 0 - Throws:
java.lang.IllegalArgumentException-if (arg == null)
-
lowerTringular
public static double[][] lowerTringular(double value, int dim)Gets a quadratic double array of dimensiondimwith all elements on and below the diagonal set tovalue.- Parameters:
value- thedoubleto store in the lower part of the arraydim- the dimension of the quadratic array- Returns:
- a
dim x dimlower triangular array - Throws:
java.lang.IllegalArgumentException-if (dim < 0),
-
maxc
public static double[] maxc(double[][] arg)
Gets a vector with the maxima of all columns ofarg.- Parameters:
arg- the original array- Returns:
- a
arg[0].lengthvector the maxima ofarg, if a column containsDouble.NaNand other double values, then the smallest double value that is not aDouble.NaNis returned - Throws:
java.lang.IllegalArgumentException-if (arg == null)or if rows of argument have different lengths
-
meanc
public static double[] meanc(double[][] arg)
Gets a vector with the mean of all columns ofarg.- Parameters:
arg- the original array- Returns:
- a
arg[0].lengthvector the mean ofarg - Throws:
java.lang.IllegalArgumentException-if (arg == null)or if rows of argument have different lengths
-
minc
public static double[] minc(double[][] arg)
Gets a vector with the minima of all columns ofarg.- Parameters:
arg- the original array- Returns:
- a
arg[0].lengthvector the minima ofarg, if a column containsDouble.NaNand other double values, then the smallest double value that is not aDouble.NaNis returned - Throws:
java.lang.IllegalArgumentException-if (arg == null)or if rows of argument have different lengths
-
multiply
public static double[][] multiply(double[][] arg, double toMult)Multiplies the scalartoMultwith a copy of the arrayarg.- Parameters:
arg- the original arraytoMult- the number to multiply all elements ofargwith- Returns:
- a new array multiplied with
toMult; iftoMultisNaN, then the resulting array will contain onlyNaN's - Throws:
java.lang.IllegalArgumentException-if (arg == null)or if rows of argument have different lengths
-
missings
public static double[][] missings(int r, int c)Gets a double array filled with NaN's.- Parameters:
r- rows of array to createc- cols of array to create- Returns:
- the
r x cdouble array filled with NaN's ornew double[0][0] if (r == 0 || c == 0) - Throws:
java.lang.IllegalArgumentException-if (r < 0 || c < 0)
-
ones
public static double[][] ones(int r, int c)Gets a double array filled with 1's.- Parameters:
r- rows of array to createc- cols of array to create- Returns:
- the
r x cdouble array filled with 1's ornew double[0][0] if (r == 0 || c == 0) - Throws:
java.lang.IllegalArgumentException-if (r < 0 || c < 0)
-
pow
public static double[][] pow(double[][] arg, double power)AppliesMath.pow(arg[i][j], power)to all elements ofarg.- Parameters:
arg- the original arraypower- the 2nd argument to be applied withMath.pow()- Returns:
- a new array with all elements raised to the power of
power - Throws:
java.lang.IllegalArgumentException-if (arg == null)or if rows of argument have different lengths
-
rank
public static int rank(double[][] arg)
Get the rank ofarg.- Parameters:
arg- the array to compute the rank from- Returns:
- the rank computed by
Jama, 0if (arg.length == 0 || arg[0].length == 0) - Throws:
java.lang.IllegalArgumentException-if (arg == null)or if rows of argument have different lengths
-
rndu
public static double[][] rndu(int r, int c)Gets a double array filled with random numbers generated byMath.random(). The random numbers are equally distributed between 0 and 1.- Parameters:
r- rows of array to createc- cols of array to create- Returns:
- the
r x cdouble array filled withMath.random()ornew double[0][0] if (r == 0 || c == 0) - Throws:
java.lang.IllegalArgumentException-if (r < 0 || c < 0)
-
selColsIf
public static double[][] selColsIf(double[][] arg, int... index)Gets all columns of the arrayargthat have a nonzero corresponding element inindex.- Parameters:
arg- the array to extract columns fromindex-arg[0].length x 1vector selecting columns fromarg- Returns:
- new array with the extracted columns,
new double[0][0]if index contains only 0's, a copy ofargifindexcontains only nonzero elements - Throws:
java.lang.IllegalArgumentException-if (arg == null || index == null)orif ((arg.length == 0 || arg[0].length == 0) && index.length > 0)orif (arg[0].length != index.length)or if rows of argument have different lengths
-
selRowsIf
public static double[][] selRowsIf(double[][] arg, int... index)Gets all rows of the arrayargthat have a nonzero corresponding element inindex.- Parameters:
arg- the array to extract rows fromindex-arg.length x 1vector selecting rows fromarg- Returns:
- new array with the extracted rows,
new double[0][0]if index contains only 0's, a copy ofargifindexcontains only nonzero elements - Throws:
java.lang.IllegalArgumentException-if (arg == null || index == null)orif ((arg.length == 0 || arg[0].length == 0) && index.length > 0)orif (arg.length != index.length)or if rows of argument have different lengths
-
seqa
public static double[] seqa(double start, double increment, int n)Gets an array with the sequence of numbers starting fromstartbeingn - 1times incremented byincrement.- Parameters:
start- the first element of the sequenceincrement- the difference between two successive elements of the sequencen- the number of elements in the sequence- Returns:
- the sequence as a
n x 1 double array - Throws:
java.lang.IllegalArgumentException-if (n < 0), or ifstart || incrementare eitherDouble.NaN,Double.NEGATIVE_INFINITYorDouble.POSITIVE_INFINITY,
-
standardize
public static double[][] standardize(double[][] arg)
Gets a new array with the elements ofargdivided by the standard devitation of the respective columns ofarg.- Parameters:
arg- the original array- Throws:
java.lang.IllegalArgumentException-if (arg == null)or if rows of argument have different lengths
-
stdc
public static double[] stdc(double[][] arg)
Gets a vector with the standard deviations of all columns ofarg. The standard deviation divisor isarg.length.- Parameters:
arg- the original array- Returns:
- a
arg[0].lengthvector the std. dev. ofarg - Throws:
java.lang.IllegalArgumentException-if (arg == null)or if rows of argument have different lengths
-
sumc
public static double[] sumc(double[][] arg)
Gets a vector with the sum of all elements in the single columns ofarg.- Parameters:
arg- the original array- Returns:
- a
arg[0].lengthvector the column sums ofarg - Throws:
java.lang.IllegalArgumentException-if (arg == null)or if rows of argument have different lengths
-
toDoubleMatrix
public static double[][] toDoubleMatrix(int[][] arg)
Transforms anintarray into adoublearray. This is sometimes needed to prepare arguments for methods that takedouble[][]instead ofint[][].- Parameters:
arg- theintarray to transform- Returns:
doublearray ornull if (arg == null)-
new double[0][0] if (arg.length == 0 || arg[0].length == 0)
- Throws:
java.lang.IllegalArgumentException- if rows of argument have different lengths
-
toDoubleMatrix
public static double[][] toDoubleMatrix(double[] arg)
Transforms a one-dimensional array into a K x 1 pseudo-two-dimensional array. This is sometimes needed to prepare arguments for methods that takedouble[][]instead ofdouble[].- Parameters:
arg- the vector-like array to transform- Returns:
- two-dimensional array with dimensions
arg.length x 1ornull if (arg == null)new double[0][0] if (arg.length == 0)
-
toDoubleMatrix
public static double[][] toDoubleMatrix(int[] arg)
Transforms a one-dimensional array into a K x 1 pseudo-two-dimensional array. This is sometimes needed to prepare arguments for methods that takedouble[][]instead ofint[].- Parameters:
arg- the vector-like array to transform- Returns:
- two-dimensional array with dimensions
arg.length x 1ornull if (arg == null)new double[0][0] if (arg.length == 0)
-
toIntMatrix
public static int[][] toIntMatrix(double[][] arg)
Transformsarginto an int array by applying a cast to int from double to each element ofarg. Note that during this operation information is potentially lost. Only the integer part is preserved, which is different from rounding. The following specialintvalues are returned:- 0 if
value == Double.NaN Integer.MAX_VALUE if value == Double.POSITIVE_INFINITYInteger.MIN_VALUE if value == Double.NEGATIVE_INFINITY
- Parameters:
arg- the array to transform- Returns:
- two-dimensional int array or
null if (arg == null)-
new int[0][0] if (g.length == 0 || g[0].length == 0)
- Throws:
java.lang.IllegalArgumentException- if rows of argument have different lengths
- 0 if
-
transpose
public static double[][] transpose(double[][] arg)
Gets a new array which is the transposearg, which means that all columns ofargare now the rows of the new array.- Parameters:
arg- the original array- Returns:
- the transpose of
arg, ornew double[0][0]if (arg.length == 0 || arg[0].length == 0) - Throws:
java.lang.IllegalArgumentException-if (arg == null)or if rows of argument have different lengths
-
vec
public static double[] vec(double[][] arg)
Get a one dimensional array with to columns ofargstacked into it.- Parameters:
arg- the array with data- Returns:
- a
arg.length * arg[0].length x 1array with the columns ofargstacked into a vector - Throws:
java.lang.IllegalArgumentException-if (arg == null)or if rows of argument have different lengths
-
vec
public static int[] vec(int[][] arg)
Get a one dimensional array with to columns ofargstacked into it.- Parameters:
arg- the array with data- Returns:
- a
arg.length * arg[0].length x 1array with the columns ofargstacked into a vector - Throws:
java.lang.IllegalArgumentException-if (arg == null)or if rows of argument have different lengths
-
conv
public static double[] conv(double[] x, double[] z, int start, int end)Computes the discrete convolution function for the vectorsxandzfromstarttoend. The function is defined as(x*z)[m] = sum_n ( x[n]z[m-n] ); m, nstart with 0.- Parameters:
x- Nx1 vectorz- Lx1 vectorstart- the first convolution to compute, zero basedend- the last convolution to compute, zero based, max number isx.length + z.length - 2;
ifend < 0, then max number is used- Returns:
- Qx1 result, where Q = (
end - start+ 1), ifend < 0, thestart'th to the last convolutions are computed - Throws:
java.lang.IllegalArgumentException-if (x == null || z == null)orif (x.length == 0 || z.length == 0)orif (start < 0)orif (start > end && end >= 0)orif (end > x.length + z.length - 2)
-
fracdiff
public static double[] fracdiff(double[] y, double d)Implementation of the fractional difference operator, see
J. R. M. Hosking "Fractional Differencing", Biometrika (1981), 68 (1), pp. 165-76 . equation 2.1.- Parameters:
y- Tx1 time series to be differencesd- order of differencing- Returns:
- Tx1 vector with differences series
- Throws:
java.lang.IllegalArgumentException-if (y == null)or ifdequalsDouble.NaN
-
-
DMelt 3.0 © DataMelt by jWork.ORG