com.jstatcom.util
Class UMatrix

java.lang.Object
  extended by com.jstatcom.util.UMatrix

public final class UMatrix
extends java.lang.Object

A 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.

Author:
Markus Kraetzig

Method Summary
static double[][] add(double[][] arg, double toAdd)
          Adds the scalar toAdd to a copy of the array arg.
static double[][] appendDoubleCols(double[][] orig, double[][] toAppend)
          Appends toAppend to the columns of orig and returns the new merged array.
static double[][] appendDoubleRows(double[][] orig, double[][] toAppend)
          Appends toAppend to the rows of orig and returns the new merged array.
static void checkRowLengths(double[][] arg)
          Checks whether all rows of arg have the same number of columns.
static void checkRowLengths(int[][] arg)
          Checks whether all rows of arg have the same number of columns.
static double[][] cloneDoubleArray(double[][] x)
          Gets an identical copy of x.
static int[][] cloneIntArray(int[][] x)
          Gets an identical copy of x.
static boolean compareDoubleArrays(double[][] arg1, double[][] arg2)
          Compares two double arrays and returns true. if the dimensions are the same and all elements are equal.
static boolean compareIntArrays(int[][] arg1, int[][] arg2)
          Compares two int arrays and returns true. if the dimensions are the same and all elements are equal.
static double[] conv(double[] x, double[] z, int start, int end)
          Computes the discrete convolution function for the vectors x and z from start to end.
static double[][] delCol(double[][] arg, int colIndex)
          Deletes the col colIndex from arg.
static double[][] delColsIf(double[][] arg, int... index)
          Deletes columns of arg that have been selected by index and returns a new array with the remaining columns.
static double[][] delRow(double[][] arg, int rowIndex)
          Deletes the row rowIndex from arg.
static double[][] delRowsIf(double[][] arg, int... index)
          Deletes rows of arg that have been selected by index and returns a new array with the remaining rows.
static double[][] eye(int dim)
          Gets an identity matrix of dimension dim.
static int[] flipIndex(int... arg)
          Gets a new array with all zero elements of arg set to one and all nonzero elements set to zero.
static java.lang.String format(double[][] arg)
          Gets a string that contains a printed version of arg.
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 array arg specified with colIndex.
static double[][] getDoubleCols(double[][] arg, int startCol, int endCol)
          Gets all columns of the array arg defined by startCol:endCol.
static double[] getDoubleRow(double[][] arg, int rowIndex)
          Gets the row of the array arg specified with rowIndex.
static double[][] getDoubleRows(double[][] arg, int startRow, int endRow)
          Gets all rows of the array arg defined by startRow:endRow.
static int getFirstNonzeroIndex(double[] arg)
          Gets the index of the first nonzero element in arg.
static int getLastNonzeroIndex(double[] arg)
          Gets the index of the last nonzero element in arg.
static int getNonzeroDoubleCount(double[] arg)
          Gets the number of nonzero elements in arg.
static int getNonzeroIntCount(int[] arg)
          Gets the number of nonzero elements in arg.
static double[][] lowerTringular(double value, int dim)
          Gets a quadratic double array of dimension dim with all elements on and below the diagonal set to value.
static double[] maxc(double[][] arg)
          Gets a vector with the maxima of all columns of arg.
static double[] meanc(double[][] arg)
          Gets a vector with the mean of all columns of arg.
static double[] minc(double[][] arg)
          Gets a vector with the minima of all columns of arg.
static double[][] missings(int r, int c)
          Gets a double array filled with NaN's.
static double[][] multiply(double[][] arg, double toMult)
          Multiplies the scalar toMult with a copy of the array arg.
static double[][] ones(int r, int c)
          Gets a double array filled with 1's.
static double[][] pow(double[][] arg, double power)
          Applies Math.pow(arg[i][j], power) to all elements of arg.
static int rank(double[][] arg)
          Get the rank of arg.
static double[][] rndu(int r, int c)
          Gets a double array filled with random numbers generated by Math.random().
static double[][] selColsIf(double[][] arg, int... index)
          Gets all columns of the array arg that have a nonzero corresponding element in index.
static double[][] selRowsIf(double[][] arg, int... index)
          Gets all rows of the array arg that have a nonzero corresponding element in index.
static double[] seqa(double start, double increment, int n)
          Gets an array with the sequence of numbers starting from start being n - 1 times incremented by increment.
static double[][] standardize(double[][] arg)
          Gets a new array with the elements of arg divided by the standard devitation of the respective columns of arg.
static double[] stdc(double[][] arg)
          Gets a vector with the standard deviations of all columns of arg.
static double[] sumc(double[][] arg)
          Gets a vector with the sum of all elements in the single columns of arg.
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 an int array into a double array.
static int[][] toIntMatrix(double[][] arg)
          Transforms arg into an int array by applying a cast to int from double to each element of arg.
static double[][] transpose(double[][] arg)
          Gets a new array which is the transpose arg, which means that all columns of arg are now the rows of the new array.
static double[] vec(double[][] arg)
          Get a one dimensional array with to columns of arg stacked into it.
static int[] vec(int[][] arg)
          Get a one dimensional array with to columns of arg stacked into it.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

add

public static double[][] add(double[][] arg,
                             double toAdd)
Adds the scalar toAdd to a copy of the array arg.

Parameters:
arg - the original array
toAdd - the number to add to all elements of arg
Returns:
a new array with toAdd added; if toAdd is NaN, then the resulting array will contain only NaN'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)
Appends toAppend to the columns of orig and returns the new merged array. This only works, if orig and toAppend have the same number of rows.

Parameters:
orig - the array to append the columns of toAppend to
toAppend - the arrays to be appended to orig
Returns:
a new array orig~toAppend
Throws:
java.lang.IllegalArgumentException - if (orig.length != toAppend.length) or if (orig == null || toAppend == null) or if rows of an argument have different lengths

appendDoubleRows

public static double[][] appendDoubleRows(double[][] orig,
                                          double[][] toAppend)
Appends toAppend to the rows of orig and returns the new merged array. This only works, if orig and toAppend have the same number of columns.

Parameters:
orig - the array to append the rows of toAppend to
toAppend - the arrays to be appended to orig
Returns:
a new array orig|toAppend
Throws:
java.lang.IllegalArgumentException - if (orig[0].length != toAppend[0].length) or if (orig == null || toAppend == null) or if rows of an argument have different lengths

checkRowLengths

public static void checkRowLengths(double[][] arg)
Checks whether all rows of arg have 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 - the double[][] to check
Throws:
java.lang.IllegalArgumentException - if the rows of arg have different lengths

checkRowLengths

public static void checkRowLengths(int[][] arg)
Checks whether all rows of arg have 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 - the int[][] to check
Throws:
java.lang.IllegalArgumentException - if the rows of arg have different lengths

cloneDoubleArray

public static double[][] cloneDoubleArray(double[][] x)
Gets an identical copy of x.

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 of x.

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 returns true. if the dimensions are the same and all elements are equal. If two elements of arg1 and arg2 are Double.NaN, they are considered to be equal, whereas arg1, arg2 are considered to be unequal if at least one of them is null.

Parameters:
arg1 - double array to compare
arg2 - double array to compare
Returns:
true if dimensions and all elements are equal or if arg1, arg2 have both at least one dimension of zero,
false otherwise
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 returns true. if the dimensions are the same and all elements are equal.

Parameters:
arg1 - int array to compare
arg2 - int array to compare
Returns:
true if dimensions and all elements are equal or if arg1, arg2 have both at least one dimension of zero,
false otherwise or if at least one argument is null
Throws:
java.lang.IllegalArgumentException - if rows of an argument have different lengths

delCol

public static double[][] delCol(double[][] arg,
                                int colIndex)
Deletes the col colIndex from arg.

Parameters:
arg - the array to delete the col from
colIndex - 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) or if (colIndex < 0 || arg[0].length < colIndex) or if (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 of arg that have been selected by index and 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 from
index - the arg[0].length x 1 int array
Returns:
a new array with the selected columns deleted or new double[0][0] if all columns where selected for deletion or if arg.length == 0
Throws:
java.lang.IllegalArgumentException - if (arg == null || index == null) or if ((arg.length == 0 || arg[0].length == 0) && index.length > 0) or if (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 row rowIndex from arg.

Parameters:
arg - the array to delete the row from
rowIndex - 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) or if (rowIndex < 0 || arg.length < rowIndex) or if (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 of arg that have been selected by index and 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 from
index - the arg[0].length x 1 int array
Returns:
a new array with the selected rows deleted or new double[0][0] if all rows where selected for deletion or if arg.length == 0
Throws:
java.lang.IllegalArgumentException - if (arg == null || index == null) or if ((arg.length == 0 || arg[0].length == 0) && index.length > 0) or if (arg.length == 0 || arg[0].length == 0) or if rows of arg have different lengths

eye

public static double[][] eye(int dim)
Gets an identity matrix of dimension dim.

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 of arg set to one and all nonzero elements set to zero. If arg is 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] if arg.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 of arg.

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 array arg specified with colIndex. The index starts with 0 as usual.

Parameters:
arg - the array to extract a column from
colIndex - 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) or if (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 array arg specified with rowIndex. The index starts with 0 as usual.

Parameters:
arg - the array to extract a row from
rowIndex - 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) or if (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 array arg defined by startCol:endCol. The indices start with 0 as usual.

Parameters:
arg - the array to extract columns from
startCol - 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) or if (arg.length == 0) or if (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 array arg defined by startRow:endRow. The indices start with 0 as usual.

Parameters:
arg - the array to extract rows from
startRow - 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) or if (arg.length == 0) or if (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 in arg.

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 in arg.

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 in arg.

Parameters:
arg - the array to check
Returns:
int the number of elements in arg that are != 0
Throws:
java.lang.IllegalArgumentException - if (arg == null)

getNonzeroIntCount

public static int getNonzeroIntCount(int[] arg)
Gets the number of nonzero elements in arg.

Parameters:
arg - the array to check, usually an index
Returns:
the number of elements in arg that are != 0
Throws:
java.lang.IllegalArgumentException - if (arg == null)

lowerTringular

public static double[][] lowerTringular(double value,
                                        int dim)
Gets a quadratic double array of dimension dim with all elements on and below the diagonal set to value.

Parameters:
value - the double to store in the lower part of the array
dim - the dimension of the quadratic array
Returns:
a dim x dim lower 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 of arg.

Parameters:
arg - the original array
Returns:
a arg[0].length vector the maxima of arg, if a column contains Double.NaN and other double values, then the smallest double value that is not a Double.NaN is 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 of arg.

Parameters:
arg - the original array
Returns:
a arg[0].length vector the mean of arg
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 of arg.

Parameters:
arg - the original array
Returns:
a arg[0].length vector the minima of arg, if a column contains Double.NaN and other double values, then the smallest double value that is not a Double.NaN is 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 scalar toMult with a copy of the array arg.

Parameters:
arg - the original array
toMult - the number to multiply all elements of arg with
Returns:
a new array multiplied with toMult; if toMult is NaN, then the resulting array will contain only NaN'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 create
c - cols of array to create
Returns:
the r x c double array filled with NaN's or new 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 create
c - cols of array to create
Returns:
the r x c double array filled with 1's or new 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)
Applies Math.pow(arg[i][j], power) to all elements of arg.

Parameters:
arg - the original array
power - the 2nd argument to be applied with Math.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 of arg.

Parameters:
arg - the array to compute the rank from
Returns:
the rank computed by Jama, 0 if (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 by Math.random(). The random numbers are equally distributed between 0 and 1.

Parameters:
r - rows of array to create
c - cols of array to create
Returns:
the r x c double array filled with Math.random() or new 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 array arg that have a nonzero corresponding element in index.

Parameters:
arg - the array to extract columns from
index - arg[0].length x 1 vector selecting columns from arg
Returns:
new array with the extracted columns, new double[0][0] if index contains only 0's, a copy of arg if index contains only nonzero elements
Throws:
java.lang.IllegalArgumentException - if (arg == null || index == null) or if ((arg.length == 0 || arg[0].length == 0) && index.length > 0) or if (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 array arg that have a nonzero corresponding element in index.

Parameters:
arg - the array to extract rows from
index - arg.length x 1 vector selecting rows from arg
Returns:
new array with the extracted rows, new double[0][0] if index contains only 0's, a copy of arg if index contains only nonzero elements
Throws:
java.lang.IllegalArgumentException - if (arg == null || index == null) or if ((arg.length == 0 || arg[0].length == 0) && index.length > 0) or if (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 from start being n - 1 times incremented by increment.

Parameters:
start - the first element of the sequence
increment - the difference between two successive elements of the sequence
n - 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 if start || increment are either Double.NaN, Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY,

standardize

public static double[][] standardize(double[][] arg)
Gets a new array with the elements of arg divided by the standard devitation of the respective columns of arg.

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 of arg. The standard deviation divisor is arg.length.

Parameters:
arg - the original array
Returns:
a arg[0].length vector the std. dev. of arg
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 of arg.

Parameters:
arg - the original array
Returns:
a arg[0].length vector the column sums of arg
Throws:
java.lang.IllegalArgumentException - if (arg == null) or if rows of argument have different lengths

toDoubleMatrix

public static double[][] toDoubleMatrix(int[][] arg)
Transforms an int array into a double array. This is sometimes needed to prepare arguments for methods that take double[][] instead of int[][].

Parameters:
arg - the int array to transform
Returns:
double array or
  • null 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 take double[][] instead of double[].

Parameters:
arg - the vector-like array to transform
Returns:
two-dimensional array with dimensions arg.length x 1 or
  • null 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 take double[][] instead of int[].

Parameters:
arg - the vector-like array to transform
Returns:
two-dimensional array with dimensions arg.length x 1 or
  • null if (arg == null)
  • new double[0][0] if (arg.length == 0)

toIntMatrix

public static int[][] toIntMatrix(double[][] arg)
Transforms arg into an int array by applying a cast to int from double to each element of arg. Note that during this operation information is potentially lost. Only the integer part is preserved, which is different from rounding. The following special int values are returned:

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

transpose

public static double[][] transpose(double[][] arg)
Gets a new array which is the transpose arg, which means that all columns of arg are now the rows of the new array.

Parameters:
arg - the original array
Returns:
the transpose of arg, or new 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 of arg stacked into it.

Parameters:
arg - the array with data
Returns:
a arg.length * arg[0].length x 1 array with the columns of arg stacked 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 of arg stacked into it.

Parameters:
arg - the array with data
Returns:
a arg.length * arg[0].length x 1 array with the columns of arg stacked 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 vectors x and z from start to end. The function is defined as

(x*z)[m] = sum_n ( x[n]z[m-n] ); m, n start with 0.

Parameters:
x - Nx1 vector
z - Lx1 vector
start - the first convolution to compute, zero based
end - the last convolution to compute, zero based, max number is x.length + z.length - 2;
if end < 0, then max number is used
Returns:
Qx1 result, where Q = (end - start+ 1), if end < 0, the start 'th to the last convolutions are computed
Throws:
java.lang.IllegalArgumentException -
  • if (x == null || z == null) or
  • if (x.length == 0 || z.length == 0) or
  • if (start < 0) or
  • if (start > end && end >= 0) or
  • if (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 differences
d - order of differencing
Returns:
Tx1 vector with differences series
Throws:
java.lang.IllegalArgumentException - if (y == null) or if d equals Double.NaN