org.astrogrid.matrix
Class Algorithms
java.lang.Object
org.astrogrid.matrix.Algorithms
public class Algorithms
- extends java.lang.Object
Some general matrix based algorithms.
- Since:
- VOTech Stage 8
- Version:
- $Name: $
- Author:
- Paul Harrison (paul.harrison@manchester.ac.uk) 8 Dec 2008
Field Summary |
static double |
eps
|
Method Summary |
static Matrix |
centre_kmeans(Matrix data,
int nclus,
int ndim)
|
static Matrix |
dist2(Matrix x,
Matrix c)
%DIST2 Calculates squared distance between two sets of points. |
static Matrix |
dist3_common(Matrix x,
Matrix centres,
no.uib.cipr.matrix.Vector covars)
|
static Matrix |
dist3_diag(Matrix x,
Matrix centres,
Matrix covars)
|
static Matrix |
dist3_free(Matrix x,
Matrix centres,
Matrix[] covars)
|
static double |
gamma(double s)
|
static void |
kmeans(Matrix centres,
Matrix data,
int niters,
double absprec,
double errprec,
boolean fromData,
boolean verbose)
Comment for kmeans
%KMEANS Trains a k means cluster model. |
static no.uib.cipr.matrix.Vector |
mean(Matrix m,
int i)
|
static no.uib.cipr.matrix.Vector |
multinorm(Matrix x,
no.uib.cipr.matrix.Vector m,
Matrix covar)
|
static int[] |
randperm(int n)
RANDPERM Random permutation. |
static int |
rem(int a,
int b)
|
static no.uib.cipr.matrix.Vector |
t_multinorm(Matrix x,
no.uib.cipr.matrix.Vector m,
Matrix covar,
double v)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
eps
public static final double eps
- See Also:
- Constant Field Values
Algorithms
public Algorithms()
kmeans
public static void kmeans(Matrix centres,
Matrix data,
int niters,
double absprec,
double errprec,
boolean fromData,
boolean verbose)
- Comment for
kmeans
%KMEANS Trains a k means cluster model.
Description
CENTRES = KMEANS(CENTRES, DATA, OPTIONS) uses the batch K-means
algorithm to set the centres of a cluster model. The matrix DATA
represents the data which is being clustered, with each row
corresponding to a vector. The sum of squares error function is used.
The point at which a local minimum is achieved is returned as
CENTRES. The error value at that point is returned in OPTIONS(8).
[CENTRES, OPTIONS, POST, ERRLOG] = KMEANS(CENTRES, DATA, OPTIONS)
also returns the cluster number (in a one-of-N encoding) for each
data point in POST and a log of the error values after each cycle in
ERRLOG. The optional parameters have the following
interpretations.
OPTIONS(1) is set to 1 to display error values; also logs error
values in the return argument ERRLOG. If OPTIONS(1) is set to 0, then
only warning messages are displayed. If OPTIONS(1) is -1, then
nothing is displayed.
OPTIONS(2) absprec is a measure of the absolute precision required for the
value of CENTRES at the solution. If the absolute difference between
the values of CENTRES between two successive steps is less than
OPTIONS(2), then this condition is satisfied.
OPTIONS(3) errprec is a measure of the precision required of the error
function at the solution. If the absolute difference between the
error functions between two successive steps is less than OPTIONS(3),
then this condition is satisfied. Both this and the previous
condition must be satisfied for termination.
OPTIONS(14) is the maximum number of iterations; default 100.
centre_kmeans
public static Matrix centre_kmeans(Matrix data,
int nclus,
int ndim)
dist2
public static Matrix dist2(Matrix x,
Matrix c)
- %DIST2 Calculates squared distance between two sets of points.
Description
D = DIST2(X, C) takes two matrices of vectors and calculates the
squared Euclidean distance between them. Both matrices must be of
the same column dimension. If X has M rows and N columns, and C has
L rows and N columns, then the result has M rows and L columns. The
I, Jth entry is the squared distance from the Ith row of X to the
Jth row of C.
- Parameters:
data
- centres
-
- Returns:
randperm
public static int[] randperm(int n)
- RANDPERM Random permutation.
RANDPERM(n) is a random permutation of the integers from 1 to n.
For example, RANDPERM(6) might be [2 4 5 6 1 3].
- Parameters:
n
-
- Returns:
dist3_common
public static Matrix dist3_common(Matrix x,
Matrix centres,
no.uib.cipr.matrix.Vector covars)
dist3_diag
public static Matrix dist3_diag(Matrix x,
Matrix centres,
Matrix covars)
dist3_free
public static Matrix dist3_free(Matrix x,
Matrix centres,
Matrix[] covars)
gamma
public static double gamma(double s)
mean
public static no.uib.cipr.matrix.Vector mean(Matrix m,
int i)
rem
public static int rem(int a,
int b)
multinorm
public static no.uib.cipr.matrix.Vector multinorm(Matrix x,
no.uib.cipr.matrix.Vector m,
Matrix covar)
t_multinorm
public static no.uib.cipr.matrix.Vector t_multinorm(Matrix x,
no.uib.cipr.matrix.Vector m,
Matrix covar,
double v)
Copyright © 2008-2010 AstroGrid. All Rights Reserved.