Classes

Matrix

Methods

distance_matrix(A, metricopt) → {Matrix}

Computes the distance matrix of datamatrix A.

Parameters:
NameTypeAttributesDefaultDescription
AMatrix

Matrix.

metricfunction<optional>
euclidean

The diistance metric.

Returns:

D - The distance matrix of A.

Type: 
Matrix

k_nearest_neigbhors(A, k, metricopt) → {Array.<Object>}

Computes the k-nearest neighbors of each row of A.

Parameters:
NameTypeAttributesDefaultDescription
AMatrix

Either the data matrix, or a distance matrix.

kNumber

The number of neighbors to compute.

metricfunction | "precomputed"<optional>
euclidean
Returns:
Type: 
Array.<Object>

linspace(start, end, numberopt) → {Array}

Creates an Array containing number numbers from start to end. If number = null.

Parameters:
NameTypeAttributesDefaultDescription
startNumber

Start value.

endNumber

End value.

numberNumber<optional>
null

Number of number between start and end.

Returns:
  • An array with number entries, beginning at start ending at end.
Type: 
Array

norm(v, metricopt) → {Number}

Computes the norm of a vector, by computing its distance to 0.

Parameters:
NameTypeAttributesDefaultDescription
vMatrix | Array.<Number> | Float64Array

Vector.

metricfunction<optional>
euclidean

Which metric should be used to compute the norm.

Returns:
  • The norm of v.
Type: 
Number

normalize(v, metric) → {Array.<Number>|Float64Array}

Normalizes Vector v.

Parameters:
NameTypeDescription
vArray.<Number> | Float64Array

Vector

metricfunction
Returns:
  • The normalized vector with length 1.
Type: 
Array.<Number> | Float64Array