Libraries.Compute.Statistics.Clustering.Cluster Documentation

This represents a Cluster in the sense that it contains a series of points that are being clumped together by a clustering algorithm. The points are contained as N-dimensional vectors and some basic add and remove style actions are allowed.

Inherits from: Libraries.Language.Object

Actions Documentation

Add(Libraries.Compute.Vector point)

Add a vector to the list.

Parameters

CalculateCentroid()

This action calculates the geometric center of the cluster of points. More information can be found about this operation on wikipedia: https://en.wikipedia.org/wiki/Centroid In this case, the action calculates the average across all dimensions, which becomes the center. This action does the calculation, but does not by default set this Vector as the point center of this cluster. This should be done only if this is the desired result.

Return

Libraries.Compute.Vector:

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Empty()

This action empties all points from the cluster.

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

GetCenter()

This returns whatever value was selected as the center of this cluster. This value may have been randomly selected, or otherwise just chosen, and as such, one should not assume that this center value is mathematically equivalent to the centroid.

Return

Libraries.Compute.Vector:

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetSize()

This returns the number of points in the current cluster.

Return

integer:

IsEmpty()

This action detects whether or not the current cluster is empty.

Return

boolean:

RemoveAt(integer i)

This action removes a point from the cluster at a particular index.

Parameters

  • integer i

Return

Libraries.Compute.Vector:

SetCenter(Libraries.Compute.Vector center)

This sets whatever value was selected as the center of this cluster. This value may have been randomly selected, or otherwise just chosen, and as such, one should not assume that this center value is mathematically equivalent to the centroid.

Parameters