## edu.stanford.nlp.math
Class ArrayMath

    java.lang.Object
      edu.stanford.nlp.math.ArrayMath

    public class ArrayMath

extends Object

Class ArrayMath

Author:
  Teg Grenager

Method Summary
`static double[]` `add(double[] a, double c)`
`static float[]` `add(float[] a, double c)`
`static void` `addInPlace(double[] a, double b)` Increases the values in this array by b.
`static void` `addInPlace(float[] a, double b)` Increases the values in this array by b.
`static void` `addMultInPlace(double[] a, double[] b, double c)` Add c times the array b to array a.
`static void` `addMultInto(double[] a, double[] b, double[] c, double d)`
`static int` `argmax_tieLast(double[] a)`
`static int` `argmax(double[] a)`
`static int` `argmax(float[] a)`
`static int` `argmax(int[] a)`
`static int` `argmin(double[] a)`
`static int` `argmin(float[] a)`
`static int` `argmin(int[] a)`
`static double` `average(double[] a)`
`static Double[]` `box(double[] assignment)`
`static Integer[]` `box(int[] assignment)`
`static int[][]` `castToInt(double[][] doubleCounts)`
`static boolean` `contains(int[] a, int i)`
`static boolean` `containsInSubarray(int[] a, int begin, int end, int i)`
`static int` `countCloseToZero(double[] v, double epsilon)`
`static int` `countInfinite(double[] v)`
`static int` `countNaN(double[] v)`
`static int` `countNegative(double[] v)`
`static int` `countNonZero(double[] v)`
`static int` `countPositive(double[] v)`
`static double[][]` `covariance(double[][] data)`
`static int[][]` `deepCopy(int[][] counts)`
`static int[]` `diag(int[][] a)` Returns diagonal elements of the given (square) matrix.
`static float[]` `doubleArrayToFloatArray(double[] a)`
`static float[][]` `doubleArrayToFloatArray(double[][] a)`
`static double[]` `exp(double[] a)`
`static void` `expInPlace(double[] a)`
`static double[]` `filterInfinite(double[] v)`
`static double[]` `filterNaN(double[] v)`
`static double[]` `filterNaNAndInfinite(double[] v)`
`static double[]` `floatArrayToDoubleArray(float[] a)`
`static double[][]` `floatArrayToDoubleArray(float[][] a)`
`static boolean` `hasInfinite(double[] a)`
`static boolean` `hasNaN(double[] a)`
`static int` `indexOf(int n, int[] a)`
`static double` `innerProduct(double[] a, double[] b)`
`static double` `innerProduct(float[] a, float[] b)`
`static double` `jensenShannonDivergence(double[] a, double[] b)` Returns the Jensen Shannon divergence (information radius) between a and b, defined as the average of the kl divergences from a to b and from b to a.
`static double` `klDivergence(double[] from, double[] to)`
`static double` `L2Norm(double[] a)`
`static double[][]` `load2DMatrixFromFile(String filename)`
`static double[]` `log(double[] a)`
`static void` `logInPlace(double[] a)`
`static void` `logNormalize(double[] a)` Makes the values in this array sum to 1.0.
`static double` `logSum(double[] logInputs)` Returns the log of the sum of an array of numbers, which are themselves input in log form.
`static double` `logSum(double[] logInputs, int fromIndex, int toIndex)` Returns the log of the portion between `fromIndex`, inclusive, and `toIndex`, exclusive, of an array of numbers, which are themselves input in log form.
`static float` `logSum(float[] logInputs)` Returns the log of the sum of an array of numbers, which are themselves input in log form.
`static double` `logSum(List<Double> logInputs)`
`static double` `logSum(List<Double> logInputs, int fromIndex, int toIndex)`
`static void` `main(String[] args)` For testing only.
`static int` `makeIntFromByte2(byte[] b, int offset)`
`static int` `makeIntFromByte4(byte[] b, int offset)`
`static double` `max(Collection<Double> a)`
`static double` `max(double[] a)`
`static float` `max(float[] a)`
`static int` `max(int[] a)`
`static int` `max(int[][] matrix)` Returns the smallest element of the matrix
`static double` `mean(double[] a)`
`static double` `median(double[] a)`
`static double` `min(double[] a)`
`static float` `min(float[] a)`
`static int` `min(int[] a)`
`static int` `min(int[][] matrix)` Returns the smallest element of the matrix
`static double[]` `multiply(double[] a, double c)` Scales the values in this array by c.
`static float[]` `multiply(float[] a, float c)` Scales the values in this array by c.
`static void` `multiplyInPlace(double[] a, double b)` Scales the values in this array by b.
`static void` `multiplyInPlace(float[] a, double b)` Scales the values in this array by b.
`static void` `multiplyInto(double[] a, double[] b, double c)`
`static double` `norm_1(double[] a)` Computes 1-norm of vector
`static double` `norm_1(float[] a)` Computes 1-norm of vector
`static double` `norm_inf(double[] a)` Computes inf-norm of vector
`static double` `norm_inf(float[] a)` Computes inf-norm of vector
`static double` `norm(double[] a)` Computes 2-norm of vector
`static double` `norm(float[] a)` Computes 2-norm of vector
`static void` `normalize(double[] a)` Makes the values in this array sum to 1.0.
`static void` `normalize(float[] a)` Makes the values in this array sum to 1.0.
`static int` `numRows(double[] v)`
`static double[]` `pairwiseAdd(double[] a, double[] b)`
`static float[]` `pairwiseAdd(float[] a, float[] b)`
`static int[]` `pairwiseAdd(int[] a, int[] b)`
`static void` `pairwiseAddInPlace(double[] to, double[] from)`
`static void` `pairwiseAddInPlace(double[] to, int[] from)`
`static void` `pairwiseAddInPlace(double[] to, short[] from)`
`static double[]` `pairwiseMultiply(double[] a, double[] b)` Assumes that both arrays have same length.
`static void` `pairwiseMultiply(double[] a, double[] b, double[] result)` Puts the result in the result array.
`static float[]` `pairwiseMultiply(float[] a, float[] b)` Assumes that both arrays have same length.
`static void` `pairwiseMultiply(float[] a, float[] b, float[] result)` Puts the result in the result array.
`static double[]` `pairwiseScaleAdd(double[] a, double[] b, double bScale)`
`static void` `pairwiseScaleAddInPlace(double[] to, double[] from, double fromScale)`
`static double[]` `pairwiseSubtract(double[] a, double[] b)`
`static float[]` `pairwiseSubtract(float[] a, float[] b)`
`static void` `pairwiseSubtractInPlace(double[] to, double[] from)`
`static double` `pearsonCorrelation(double[] x, double[] y)` Direct computation of Pearson product-moment correlation coefficient.
`static double[]` `pow(double[] a, double c)` raises each entry in array a by power c
`static float[]` `pow(float[] a, float c)` raises each entry in array a by power c
`static void` `powInPlace(double[] a, double c)` Scales the values in this array by c.
`static void` `powInPlace(float[] a, float c)` Sets the values in this array by to their value taken to cth power.
`static void` `reverse(int[] a)`
`static double` `safeMax(double[] v)` Returns the largest value in a vector of doubles.
`static double` `safeMean(double[] v)` Returns the mean of a vector of doubles.
`static double` `safeMin(double[] v)` Returns the largest value in a vector of doubles.
`static double` `safeStdev(double[] v)` Returns the standard deviation of a vector of doubles.
`static int` `sampleFromDistribution(double[] d)` Samples from the distribution over values 0 through d.length given by d.
`static int` `sampleFromDistribution(double[] d, Random random)` Samples from the distribution over values 0 through d.length given by d.
`static int` `sampleFromDistribution(float[] d, Random random)` Samples from the distribution over values 0 through d.length given by d.
`static void` `sampleWithoutReplacement(int[] array, int numArgClasses)` Fills the array with sample from 0 to numArgClasses-1 without replacement.
`static void` `sampleWithoutReplacement(int[] array, int numArgClasses, Random rand)` Fills the array with sample from 0 to numArgClasses-1 without replacement.
`static void` `setToLogDeterministic(double[] a, int i)`
`static void` `setToLogDeterministic(float[] a, int i)`
`static void` `shuffle(int[] a)`
`static void` `shuffle(int[] a, Random rand)`
`static double` `sigLevelByApproxRand(boolean[] A, boolean[] B)`
`static double` `sigLevelByApproxRand(boolean[] A, boolean[] B, int iterations)`
`static double` `sigLevelByApproxRand(double[] A, double[] B)` Computes the significance level by approximate randomization, using a default value of 1000 iterations.
`static double` `sigLevelByApproxRand(double[] A, double[] B, int iterations)` Takes a pair of arrays, A and B, which represent corresponding outcomes of a pair of random variables: say, results for two different classifiers on a sequence of inputs.
`static double` `sigLevelByApproxRand(int[] A, int[] B)`
`static double` `sigLevelByApproxRand(int[] A, int[] B, int iterations)`
`static double` `standardErrorOfMean(double[] a)`
`static void` `standardize(double[] a)` Standardize values in this array, i.e., subtract the mean and divide by the standard deviation.
`static double` `stdev(double[] a)`
`static int[]` `subArray(int[] a, int from, int to)`
`static double` `sum(double[] a)` Returns the sum of an array of numbers.
`static double` `sum(double[] a, int fromIndex, int toIndex)` Returns the sum of the portion of an array of numbers between `fromIndex`, inclusive, and `toIndex`, exclusive.
`static float` `sum(float[] a)`
`static int` `sum(int[] a)`
`static int` `sum(int[][] a)`
`static double` `sumSquared(double[] a)`
`static double` `sumSquaredError(double[] a)`
`static String` `toBinaryString(byte[] b)`
`static String` `toString(byte[] a)`
`static String` `toString(byte[] a, NumberFormat nf)`
`static String` `toString(double[] a)`
`static String` `toString(double[][] counts)`
`static String` `toString(double[][] counts, int cellSize, Object[] rowLabels, Object[] colLabels, NumberFormat nf, boolean printTotals)`
`static String` `toString(double[] a, NumberFormat nf)`
`static String` `toString(float[] a)`
`static String` `toString(float[][] counts)`
`static String` `toString(float[][] counts, int cellSize, Object[] rowLabels, Object[] colLabels, NumberFormat nf, boolean printTotals)`
`static String` `toString(float[] a, NumberFormat nf)`
`static String` `toString(int[] a)`
`static String` `toString(int[][] counts)`
`static String` `toString(int[][] counts, Object[] rowLabels, Object[] colLabels, int labelSize, int cellSize, NumberFormat nf, boolean printTotals)`
`static String` `toString(int[] a, NumberFormat nf)`
`static double[]` `unbox(Collection<Double> list)`
`static int[]` `unboxToInt(Collection<Integer> list)`
`static double` `variance(double[] a)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### numRows

    public static int numRows(double[] v)

### doubleArrayToFloatArray

    public static float[] doubleArrayToFloatArray(double[] a)

### floatArrayToDoubleArray

    public static double[] floatArrayToDoubleArray(float[] a)

### floatArrayToDoubleArray

    public static double[][] floatArrayToDoubleArray(float[][] a)

### doubleArrayToFloatArray

    public static float[][] doubleArrayToFloatArray(double[][] a)

### makeIntFromByte4

    public static int makeIntFromByte4(byte[] b,
                                       int offset)

### makeIntFromByte2

    public static int makeIntFromByte2(byte[] b,
                                       int offset)

### exp

    public static double[] exp(double[] a)

### log

    public static double[] log(double[] a)

### expInPlace

    public static void expInPlace(double[] a)

### logInPlace

    public static void logInPlace(double[] a)

### addInPlace

    public static void addInPlace(double[] a,
                                  double b)

  Increases the values in this array by b. Does it in place.

  Parameters:
    `a` - The array
    `b` - The amount by which to increase each item

### addInPlace

    public static void addInPlace(float[] a,
                                  double b)

  Increases the values in this array by b. Does it in place.

  Parameters:
    `a` - The array
    `b` - The amount by which to increase each item

### addMultInPlace

    public static void addMultInPlace(double[] a,
                                      double[] b,
                                      double c)

  Add c times the array b to array a. Does it in place.

### multiplyInPlace

    public static void multiplyInPlace(double[] a,
                                       double b)

  Scales the values in this array by b. Does it in place.

### multiplyInPlace

    public static void multiplyInPlace(float[] a,
                                       double b)

  Scales the values in this array by b. Does it in place.

### powInPlace

    public static void powInPlace(double[] a,
                                  double c)

  Scales the values in this array by c.

### powInPlace

    public static void powInPlace(float[] a,
                                  float c)

  Sets the values in this array by to their value taken to cth power.

### add

    public static double[] add(double[] a,
                               double c)

### add

    public static float[] add(float[] a,
                              double c)

### multiply

    public static double[] multiply(double[] a,
                                    double c)

  Scales the values in this array by c.

### multiply

    public static float[] multiply(float[] a,
                                   float c)

  Scales the values in this array by c.

### pow

    public static double[] pow(double[] a,
                               double c)

  raises each entry in array a by power c

### pow

    public static float[] pow(float[] a,
                              float c)

  raises each entry in array a by power c

### pairwiseAddInPlace

    public static void pairwiseAddInPlace(double[] to,
                                          double[] from)

### pairwiseAddInPlace

    public static void pairwiseAddInPlace(double[] to,
                                          int[] from)

### pairwiseAddInPlace

    public static void pairwiseAddInPlace(double[] to,
                                          short[] from)

### pairwiseSubtractInPlace

    public static void pairwiseSubtractInPlace(double[] to,
                                               double[] from)

### pairwiseScaleAddInPlace

    public static void pairwiseScaleAddInPlace(double[] to,
                                               double[] from,
                                               double fromScale)

### pairwiseAdd

    public static int[] pairwiseAdd(int[] a,
                                    int[] b)

### pairwiseAdd

    public static double[] pairwiseAdd(double[] a,
                                       double[] b)

### pairwiseAdd

    public static float[] pairwiseAdd(float[] a,
                                      float[] b)

### pairwiseScaleAdd

    public static double[] pairwiseScaleAdd(double[] a,
                                            double[] b,
                                            double bScale)

### pairwiseSubtract

    public static double[] pairwiseSubtract(double[] a,
                                            double[] b)

### pairwiseSubtract

    public static float[] pairwiseSubtract(float[] a,
                                           float[] b)

### pairwiseMultiply

    public static double[] pairwiseMultiply(double[] a,
                                            double[] b)

  Assumes that both arrays have same length.

### pairwiseMultiply

    public static float[] pairwiseMultiply(float[] a,
                                           float[] b)

  Assumes that both arrays have same length.

### pairwiseMultiply

    public static void pairwiseMultiply(double[] a,
                                        double[] b,
                                        double[] result)

  Puts the result in the result array. Assumes that all arrays have same length.

### pairwiseMultiply

    public static void pairwiseMultiply(float[] a,
                                        float[] b,
                                        float[] result)

  Puts the result in the result array. Assumes that all arrays have same length.

### hasNaN

    public static boolean hasNaN(double[] a)

### hasInfinite

    public static boolean hasInfinite(double[] a)

### countNaN

    public static int countNaN(double[] v)

### filterNaN

    public static double[] filterNaN(double[] v)

### countInfinite

    public static int countInfinite(double[] v)

### countNonZero

    public static int countNonZero(double[] v)

### countCloseToZero

    public static int countCloseToZero(double[] v,
                                       double epsilon)

### countPositive

    public static int countPositive(double[] v)

### countNegative

    public static int countNegative(double[] v)

### filterInfinite

    public static double[] filterInfinite(double[] v)

### filterNaNAndInfinite

    public static double[] filterNaNAndInfinite(double[] v)

### sum

    public static double sum(double[] a)

  Returns the sum of an array of numbers.

### sum

    public static double sum(double[] a,
                             int fromIndex,
                             int toIndex)

  Returns the sum of the portion of an array of numbers between `fromIndex`, inclusive, and `toIndex`, exclusive. Returns 0 if `fromIndex` >= `toIndex`.

### sum

    public static int sum(int[] a)

### sum

    public static float sum(float[] a)

### sum

    public static int sum(int[][] a)

### diag

    public static int[] diag(int[][] a)

  Returns diagonal elements of the given (square) matrix.

### average

    public static double average(double[] a)

### norm_inf

    public static double norm_inf(double[] a)

  Computes inf-norm of vector

  Parameters:
    `a` - Array of double
  Returns:
    inf-norm of a

### norm_inf

    public static double norm_inf(float[] a)

  Computes inf-norm of vector

  Returns:
    inf-norm of a

### norm_1

    public static double norm_1(double[] a)

  Computes 1-norm of vector

  Parameters:
    `a` - A vector of double
  Returns:
    1-norm of a

### norm_1

    public static double norm_1(float[] a)

  Computes 1-norm of vector

  Parameters:
    `a` - A vector of floats
  Returns:
    1-norm of a

### norm

    public static double norm(double[] a)

  Computes 2-norm of vector

  Parameters:
    `a` - A vector of double
  Returns:
    Euclidean norm of a

### norm

    public static double norm(float[] a)

  Computes 2-norm of vector

  Parameters:
    `a` - A vector of floats
  Returns:
    Euclidean norm of a

### argmax

    public static int argmax(double[] a)

  Returns:
    the index of the max value; if max is a tie, returns the first one.

### argmax_tieLast

    public static int argmax_tieLast(double[] a)

  Returns:
    the index of the max value; if max is a tie, returns the last one.

### max

    public static double max(double[] a)

### max

    public static double max(Collection<Double> a)

### argmax

    public static int argmax(float[] a)

  Returns:
    the index of the max value; if max is a tie, returns the first one.

### max

    public static float max(float[] a)

### argmin

    public static int argmin(double[] a)

  Returns:
    the index of the max value; if max is a tie, returns the first one.

### min

    public static double min(double[] a)

### safeMin

    public static double safeMin(double[] v)

  Returns the largest value in a vector of doubles. Any values which are NaN or infinite are ignored. If the vector is empty, 0.0 is returned.

### argmin

    public static int argmin(float[] a)

  Returns:
    the index of the max value; if max is a tie, returns the first one.

### min

    public static float min(float[] a)

### argmin

    public static int argmin(int[] a)

  Returns:
    the index of the max value; if max is a tie, returns the first one.

### min

    public static int min(int[] a)

### argmax

    public static int argmax(int[] a)

  Returns:
    the index of the max value; if max is a tie, returns the first one.

### max

    public static int max(int[] a)

### min

    public static int min(int[][] matrix)

  Returns the smallest element of the matrix

### max

    public static int max(int[][] matrix)

  Returns the smallest element of the matrix

### safeMax

    public static double safeMax(double[] v)

  Returns the largest value in a vector of doubles. Any values which are NaN or infinite are ignored. If the vector is empty, 0.0 is returned.

### logSum

    public static double logSum(double[] logInputs)

  Returns the log of the sum of an array of numbers, which are themselves input in log form. This is all natural logarithms. Reasonable care is taken to do this as efficiently as possible (under the assumption that the numbers might differ greatly in magnitude), with high accuracy, and without numerical overflow.

  Parameters:
    `logInputs` - An array of numbers [log(x1), ..., log(xn)]
  Returns:
    log(x1 + ... + xn)

### logSum

    public static double logSum(double[] logInputs,
                                int fromIndex,
                                int toIndex)

  Returns the log of the portion between `fromIndex`, inclusive, and `toIndex`, exclusive, of an array of numbers, which are themselves input in log form. This is all natural logarithms. Reasonable care is taken to do this as efficiently as possible (under the assumption that the numbers might differ greatly in magnitude), with high accuracy, and without numerical overflow. Throws an `IllegalArgumentException` if `logInputs` is of length zero. Otherwise, returns Double.NEGATIVE_INFINITY if `fromIndex` >= `toIndex`.

  Parameters:
    `logInputs` - An array of numbers [log(x1), ..., log(xn)]
    `fromIndex` - the
  Returns:
    log(x1 + ... + xn)

### logSum

    public static double logSum(List<Double> logInputs)

### logSum

    public static double logSum(List<Double> logInputs,
                                int fromIndex,
                                int toIndex)

### logSum

    public static float logSum(float[] logInputs)

  Returns the log of the sum of an array of numbers, which are themselves input in log form. This is all natural logarithms. Reasonable care is taken to do this as efficiently as possible (under the assumption that the numbers might differ greatly in magnitude), with high accuracy, and without numerical overflow.

  Parameters:
    `logInputs` - An array of numbers [log(x1), ..., log(xn)]
  Returns:
    log(x1 + ... + xn)

### innerProduct

    public static double innerProduct(double[] a,
                                      double[] b)

### innerProduct

    public static double innerProduct(float[] a,
                                      float[] b)

### subArray

    public static int[] subArray(int[] a,
                                 int from,
                                 int to)

### load2DMatrixFromFile

    public static double[][] load2DMatrixFromFile(String filename)
                                           throws IOException

  Throws:
    `IOException`

### box

    public static Integer[] box(int[] assignment)

### unboxToInt

    public static int[] unboxToInt(Collection<Integer> list)

### box

    public static Double[] box(double[] assignment)

### unbox

    public static double[] unbox(Collection<Double> list)

### indexOf

    public static int indexOf(int n,
                              int[] a)

### castToInt

    public static int[][] castToInt(double[][] doubleCounts)

### normalize

    public static void normalize(double[] a)

  Makes the values in this array sum to 1.0. Does it in place. If the total is 0.0 or NaN, throws an RuntimeException.

### normalize

    public static void normalize(float[] a)

  Makes the values in this array sum to 1.0. Does it in place. If the total is 0.0 or NaN, throws an RuntimeException.

### standardize

    public static void standardize(double[] a)

  Standardize values in this array, i.e., subtract the mean and divide by the standard deviation. If standard deviation is 0.0, throws an RuntimeException.

### L2Norm

    public static double L2Norm(double[] a)

### logNormalize

    public static void logNormalize(double[] a)

  Makes the values in this array sum to 1.0. Does it in place. If the total is 0.0, throws a RuntimeException. If the total is Double.NEGATIVE_INFINITY, then it replaces the array with a normalized uniform distribution. CDM: This last bit is weird! Do we really want that?

### sampleFromDistribution

    public static int sampleFromDistribution(double[] d)

  Samples from the distribution over values 0 through d.length given by d. Assumes that the distribution sums to 1.0.

  Parameters:
    `d` - the distribution to sample from
  Returns:
    a value from 0 to d.length

### sampleFromDistribution

    public static int sampleFromDistribution(double[] d,
                                             Random random)

  Samples from the distribution over values 0 through d.length given by d. Assumes that the distribution sums to 1.0.

  Parameters:
    `d` - the distribution to sample from
  Returns:
    a value from 0 to d.length

### sampleFromDistribution

    public static int sampleFromDistribution(float[] d,
                                             Random random)

  Samples from the distribution over values 0 through d.length given by d. Assumes that the distribution sums to 1.0.

  Parameters:
    `d` - the distribution to sample from
  Returns:
    a value from 0 to d.length

### klDivergence

    public static double klDivergence(double[] from,
                                      double[] to)

### jensenShannonDivergence

    public static double jensenShannonDivergence(double[] a,
                                                 double[] b)

  Returns the Jensen Shannon divergence (information radius) between a and b, defined as the average of the kl divergences from a to b and from b to a.

### setToLogDeterministic

    public static void setToLogDeterministic(float[] a,
                                             int i)

### setToLogDeterministic

    public static void setToLogDeterministic(double[] a,
                                             int i)

### mean

    public static double mean(double[] a)

### median

    public static double median(double[] a)

### safeMean

    public static double safeMean(double[] v)

  Returns the mean of a vector of doubles. Any values which are NaN or infinite are ignored. If the vector is empty, 0.0 is returned.

### sumSquaredError

    public static double sumSquaredError(double[] a)

### sumSquared

    public static double sumSquared(double[] a)

### variance

    public static double variance(double[] a)

### stdev

    public static double stdev(double[] a)

### safeStdev

    public static double safeStdev(double[] v)

  Returns the standard deviation of a vector of doubles. Any values which are NaN or infinite are ignored. If the vector contains fewer than two values, 1.0 is returned.

### standardErrorOfMean

    public static double standardErrorOfMean(double[] a)

### sampleWithoutReplacement

    public static void sampleWithoutReplacement(int[] array,
                                                int numArgClasses)

  Fills the array with sample from 0 to numArgClasses-1 without replacement.

### sampleWithoutReplacement

    public static void sampleWithoutReplacement(int[] array,
                                                int numArgClasses,
                                                Random rand)

  Fills the array with sample from 0 to numArgClasses-1 without replacement.

### shuffle

    public static void shuffle(int[] a)

### shuffle

    public static void shuffle(int[] a,
                               Random rand)

### reverse

    public static void reverse(int[] a)

### contains

    public static boolean contains(int[] a,
                                   int i)

### containsInSubarray

    public static boolean containsInSubarray(int[] a,
                                             int begin,
                                             int end,
                                             int i)

### pearsonCorrelation

    public static double pearsonCorrelation(double[] x,
                                            double[] y)

  Direct computation of Pearson product-moment correlation coefficient. Note that if x and y are involved in several computations of pearsonCorrelation, it is perhaps more advisable to first standardize x and y, then compute innerProduct(x,y)/(x.length-1).

### sigLevelByApproxRand

    public static double sigLevelByApproxRand(double[] A,
                                              double[] B)

  Computes the significance level by approximate randomization, using a default value of 1000 iterations. See documentation for other version of method.

### sigLevelByApproxRand

    public static double sigLevelByApproxRand(double[] A,
                                              double[] B,
                                              int iterations)

  Takes a pair of arrays, A and B, which represent corresponding outcomes of a pair of random variables: say, results for two different classifiers on a sequence of inputs. Returns the estimated probability that the difference between the means of A and B is not significant, that is, the significance level. This is computed by "approximate randomization". The test statistic is the absolute difference between the means of the two arrays. A randomized test statistic is computed the same way after initially randomizing the arrays by swapping each pair of elements with 50% probability. For the given number of iterations, we generate a randomized test statistic and compare it to the actual test statistic. The return value is the proportion of iterations in which a randomized test statistic was found to exceed the actual test statistic.

  Parameters:
    `A` - Outcome of one r.v.
    `B` - Outcome of another r.v.
  Returns:
    Significance level by randomization

### sigLevelByApproxRand

    public static double sigLevelByApproxRand(int[] A,
                                              int[] B)

### sigLevelByApproxRand

    public static double sigLevelByApproxRand(int[] A,
                                              int[] B,
                                              int iterations)

### sigLevelByApproxRand

    public static double sigLevelByApproxRand(boolean[] A,
                                              boolean[] B)

### sigLevelByApproxRand

    public static double sigLevelByApproxRand(boolean[] A,
                                              boolean[] B,
                                              int iterations)

### toBinaryString

    public static String toBinaryString(byte[] b)

### toString

    public static String toString(double[] a)

### toString

    public static String toString(double[] a,
                                  NumberFormat nf)

### toString

    public static String toString(float[] a)

### toString

    public static String toString(float[] a,
                                  NumberFormat nf)

### toString

    public static String toString(int[] a)

### toString

    public static String toString(int[] a,
                                  NumberFormat nf)

### toString

    public static String toString(byte[] a)

### toString

    public static String toString(byte[] a,
                                  NumberFormat nf)

### toString

    public static String toString(int[][] counts)

### toString

    public static String toString(int[][] counts,
                                  Object[] rowLabels,
                                  Object[] colLabels,
                                  int labelSize,
                                  int cellSize,
                                  NumberFormat nf,
                                  boolean printTotals)

### toString

    public static String toString(double[][] counts)

### toString

    public static String toString(double[][] counts,
                                  int cellSize,
                                  Object[] rowLabels,
                                  Object[] colLabels,
                                  NumberFormat nf,
                                  boolean printTotals)

### toString

    public static String toString(float[][] counts)

### toString

    public static String toString(float[][] counts,
                                  int cellSize,
                                  Object[] rowLabels,
                                  Object[] colLabels,
                                  NumberFormat nf,
                                  boolean printTotals)

### main

    public static void main(String[] args)

  For testing only.

  Parameters:
    `args` - Ignored

### deepCopy

    public static int[][] deepCopy(int[][] counts)

### covariance

    public static double[][] covariance(double[][] data)

### addMultInto

    public static void addMultInto(double[] a,
                                   double[] b,
                                   double[] c,
                                   double d)

### multiplyInto

    public static void multiplyInto(double[] a,
                                    double[] b,
                                    double c)

Stanford NLP Group