Sautrela

edu.gtts.sautrela.vq
Class Cluster

java.lang.Object
  extended by edu.gtts.sautrela.vq.Cluster

public class Cluster
extends java.lang.Object

A cluster that contains a Collection of multidimensional data. The centroid of the cluster is not changed when data is added or removed. It can be only set in the constructor or updated to the less distorsion point. The distorsion is a dinamic magnitude that depends on the current centroid and all the data contained in the Cluster.


Constructor Summary
Cluster()
          Creates a new empty Cluster.
Cluster(double[] centroid)
          Creates a new Cluster with a desired centroid.
 
Method Summary
 void addData(java.util.Collection<double[]> c)
          Adds a Collection of data to this Cluster.
 void addData(double[] v)
          Adds new data to this Cluster.
 void addData(double[] v, double sqrDist)
          Adds new data to this Cluster using a previously obtained square distance.
 double[] createSymmetrical(double[] d)
          Creates a new symmetrical data respect to the current centroid.
 double[] getCentroid()
          Returns the current centroid of this Cluster.
 java.util.Collection<double[]> getData()
          Gets all the data contained in this Cluster.
 double getDistance(double[] v)
          Computes the Euclidean distance between the current centroid and the given data.
 double getDistorsion()
          Returns the current distorsion of this Cluster.
 double[] getRandomData()
          Gets randomly a data out of all data contained in this Cluster.
 double getSquareDistance(double[] v)
          Computes the square of the Euclidean distance between the current centroid and the given data.
 void removeData()
          Clears all data contained in this Cluster.
 int size()
          Returns the amount of data in this Cluster.
 void update()
          Updates the current centroid in order to get the minimun distorsion.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cluster

public Cluster()
Creates a new empty Cluster.


Cluster

public Cluster(double[] centroid)
Creates a new Cluster with a desired centroid.

Parameters:
centroid - the initial centroid.
Method Detail

size

public int size()
Returns the amount of data in this Cluster.

Returns:
the amount of data in this Cluster.

getSquareDistance

public double getSquareDistance(double[] v)
Computes the square of the Euclidean distance between the current centroid and the given data. The centroid could not be the mean one.

Parameters:
v - the data
Returns:
the distorsion between the current centroid and the given data.

getDistance

public double getDistance(double[] v)
Computes the Euclidean distance between the current centroid and the given data. The centroid could not be the mean one.

Parameters:
v - the data
Returns:
the Euclidean distance between the current centroid and the data

addData

public void addData(double[] v)
Adds new data to this Cluster. The distorsion of the cluster is updated.

Parameters:
v - data to be added

addData

public void addData(double[] v,
                    double sqrDist)
Adds new data to this Cluster using a previously obtained square distance. This distance is used to update the cluster distorsion.

Parameters:
v - data to be added
sqrDist - square distance to the centroid

addData

public void addData(java.util.Collection<double[]> c)
Adds a Collection of data to this Cluster. The distorsion of the cluster is updated.

Parameters:
c - data elements to be added.

getData

public java.util.Collection<double[]> getData()
Gets all the data contained in this Cluster.

Returns:
the data contained in this Cluster.

getRandomData

public double[] getRandomData()
Gets randomly a data out of all data contained in this Cluster.

Returns:
the random data.

removeData

public void removeData()
Clears all data contained in this Cluster.


getCentroid

public double[] getCentroid()
Returns the current centroid of this Cluster.

Returns:
the current centroid.

createSymmetrical

public double[] createSymmetrical(double[] d)
Creates a new symmetrical data respect to the current centroid.

Parameters:
d - the source data.
Returns:
the symmetrical data.

getDistorsion

public double getDistorsion()
Returns the current distorsion of this Cluster.

Returns:
the current distorsion.

update

public void update()
Updates the current centroid in order to get the minimun distorsion. The centroid is updates as the mean of all data and the distorsion is also updated.


Sautrela