jminhep.cluster
Class DataPoint
- java.lang.Object
-
- jminhep.cluster.DataPoint
-
- All Implemented Interfaces:
- java.io.Serializable
public class DataPoint extends java.lang.Object implements java.io.SerializableRepresents an abstraction for a data point in many-dimensional space- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description DataPoint(double[] xx)Creates a new instance of a data pointDataPoint(double[] xx, int dim)Creates a new instance of a data point
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidassignToCluster(int _clusterNumber)Assigns the data point to a clusterstatic doubledistance(DataPoint dp1, DataPoint dp2)Returns the distance between two data pointsstatic doubledistanceSqrt(DataPoint dp1, DataPoint dp2)Returns the squared distance between two data pointsdoublegetAttribute(int index)Returns the attribute of data pointintgetClusterNumber()Returns the cluster to which the data point belongsintgetDimension()Get dimension of the pointstatic voidmain(java.lang.String[] args)Main method -- to test the DataPoint classvoidshowAttributes()Print all attributes of a data pointjava.lang.StringtoString()Returns a string representation of this DataPoint
-
-
-
Constructor Detail
-
DataPoint
public DataPoint(double[] xx, int dim)Creates a new instance of a data point- Parameters:
xx- array of dimension dimdim- dimension
-
DataPoint
public DataPoint(double[] xx)
Creates a new instance of a data point- Parameters:
xx- array
-
-
Method Detail
-
getDimension
public int getDimension()
Get dimension of the point- Returns:
- dimension (int)
-
assignToCluster
public void assignToCluster(int _clusterNumber)
Assigns the data point to a cluster- Parameters:
_clusterNumber- the cluster to which this data point is to be assigned
-
getClusterNumber
public int getClusterNumber()
Returns the cluster to which the data point belongs- Returns:
- the cluster number to which the data point belongs
-
getAttribute
public double getAttribute(int index)
Returns the attribute of data point- Parameters:
index- current idex- Returns:
- the value in many dimensions
-
showAttributes
public void showAttributes()
Print all attributes of a data point
-
distance
public static double distance(DataPoint dp1, DataPoint dp2)
Returns the distance between two data points- Parameters:
dp1- the first data pointdp2- the second data point- Returns:
- the distance between the two data points (double)
-
distanceSqrt
public static double distanceSqrt(DataPoint dp1, DataPoint dp2)
Returns the squared distance between two data points- Parameters:
dp1- the first data pointdp2- the second data point- Returns:
- the distance between the two data points
-
toString
public java.lang.String toString()
Returns a string representation of this DataPoint- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation of this data point
-
main
public static void main(java.lang.String[] args)
Main method -- to test the DataPoint class- Parameters:
args- command line arguments
-
-
DMelt 3.0 © DataMelt by jWork.ORG