Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
mdsj.Data
public class Data
extends java.lang.Object
Method Summary | |
static double |
|
static double[][] |
|
static void |
|
static String |
|
static int[] |
|
static double[][] |
|
static double[][] |
|
static void |
|
static double |
|
static void |
|
static double[][] |
|
static double |
|
static double[][] |
|
static void |
|
static void |
|
static void |
|
static void |
|
static void |
|
public static double distance(double[][] matrix, int i, int j)
Gives the Euclidean distances of two data points in a data matrix. It is computed as(sum(matrix[*][i]-matrix[*][i])^2)^(1/2)
, where the sum is over all row indices, indicated by*
.
- Parameters:
matrix
- the data matrixi
- the index of a data pointj
- the index of a data point
- Returns:
- the Euclidean distance between the two data points
public static double[][] distanceMatrix(double[][] matrix)
Gives the complete matrix of Euclidean distances in a configuration of data points inD
-dimensional Euclidean space, whereD=matrix[0].length
.
- Parameters:
matrix
- high-dimensional coordinates for data pointss
- Returns:
- matrix of Euclidean distances among the data points
public static void doubleCenter(double[][] matrix)
Double-centers the matrix so that each rows and each columns sums to zero, by subtracting the row mean in each row, subtracting the column mean in each column, and adding the overall mean for each entry.
- Parameters:
matrix
- the matrix to be double-centered
public static String format(double[][] matrix)
Print all entries of a matrix. Each row in the matrix gets a space-separated line representation.
- Parameters:
matrix
- the matrix to be printed
- Returns:
- a string representation of the matrix
public static int[] landmarkIndices(double[][] matrix)
From a rectangular k x n matrix of dissimilarities, an index array of length k is computed. The entry at positioni/code> is the original index in the range
[0,n-1]
for which thei
-th row in the original matrix stands.
- Parameters:
matrix
- a rectangular k x n dissimilarity matrix
- Returns:
- array of indices of length k
public static double[][] landmarkMatrix(double[][] matrix)
From a rectangular k x n matrix of dissimilarities, a square k x k dissimilarity matrix is computed which contains just the dissimilarities among the k objects described by the k rows.
- Parameters:
matrix
-
- Returns:
- a square dissimilarity matrix
public static double[][] maxminPivotMatrix(double[][] matrix, int k)
Gives a pivot matrix for a configuration of data points in Euclidean space. The result is a subset of columns of the matrix of Euclidean distances. A point whose columns is to be included is called pivot. The pivots are selected with a maxmin strategy. The first pivot is selected randomly; thei
-th pivot is selected to maximize the minimum Euclidean distance to thei-1
pivots selected so far.
- Parameters:
matrix
- coordinates of the pointsk
- number of pivots
- Returns:
- the pivot matrix of Euclidean distances
public static void multiply(double[][] matrix, double factor)
Scales each entry in a matrix by a factor.
- Parameters:
matrix
- the matrixfactor
- the scaling factor
public static double normalize(double[] x)
Normalizes a vector to have unit length
- Parameters:
x
- a vector
- Returns:
- the vector's former length
public static void normalize(double[][] x)
Scales every column of a matrix to have length one.
- Parameters:
x
- A matrix
public static double[][] pivotRows(double[][] matrix, int k)
Given a set of dissimilarity rows, a subsample of rows is constructed which should be as representative as possible, using a greedy farthest-minimal dissimilarity approach. The number of rows to be selected must not be larger than the number of rows present in the input matrix, i.e.,k<=matrix.length
. The indices in the second dimension (i.e., within every row) are the actual ones. The indices in the first dimension are meaningless, but the original index corresponding to a rowi
may be determined by checking for whichj
the equalityd[i][j]=0
holds.
- Parameters:
matrix
- a collection of dissmilarity rowsk
- the number of rows to be selected
- Returns:
- a subset of the original dissimilarity rows
public static double prod(double[] x, double[] y)
Computes inner product of two vectors of the same length, the sum of entry-wise productsx[0]*y[0]+...+x[n-1]*y[n-1]
, wheren
is the minimum length of the vectors
- Parameters:
x
- a vectory
- a vector
- Returns:
- the inner product of the vectors
public static double[][] randomPivotMatrix(double[][] matrix, int k)
Gives a pivot matrix for a configuration of data points in Euclidean space. The result is a subset of columns of the matrix of Euclidean distances. A point whose column is to be included is called pivot. The pivots are selected at random; it is possible for a point to be selected as pivot more than once.
- Parameters:
matrix
- coordinates of the pointsk
- number of pivots
- Returns:
- the pivot matrix of Euclidean distances
public static void randomize(double[][] matrix)
Fills a matrix with pseudo-random entries in the range-0.5
to0.5
with uniformly probability distribution. This is useful for initializing the iterative computation of eigenvectors
- Parameters:
matrix
- the matrix to be filled
public static void scale(double[][] x, double[][] D)
Scales a configuration such that the sum of the corresponding distances equals the sum of the input dissimilarities
- Parameters:
x
- configuration matrixD
- square matrix of input dissimilarities
public static void selfprod(double[][] d, double[][] result)
Computes the self product of a matrixd
with its transposed'
.
- Parameters:
d
- the matrixresult
- the (symmetric) productdd'
public static void squareDoubleCenter(double[][] matrix)
Squares each entry of a matrix and then double-centers it.
- Parameters:
matrix
- the matrix
public static void squareEntries(double[][] matrix)
Squares each entry in a matrix.
- Parameters:
matrix
- the matrix