KMeansTData, TDataSum Constructor |
Namespace: Altaxo.Calc.ClusteringAssembly: AltaxoCore (in AltaxoCore.dll) Version: 4.8.3179.0 (4.8.3179.0)
Syntax public KMeans(
Func<TDataSum> createDefaultFunction,
Func<TDataSum, TData, double> distanceFunction,
bool isDistanceFunctionReturningSquareOfDistance,
Func<TDataSum, TData, TDataSum> sumUpFunction,
Func<TDataSum, int, TDataSum> divideFunction
)
Parameters
- createDefaultFunction FuncTDataSum
- Creates the default data. Sum up the default data and other data should result in the same value of the other data.
- distanceFunction FuncTDataSum, TData, Double
-
A function that evaluates the distance between the mean value of the cluster and a data point.
The return value is either the Euclidean distance, or the square of the distance. In the latter case
the next argument must be set to true.
- isDistanceFunctionReturningSquareOfDistance Boolean
- True if the distanceFunction returns the square of the distance.
- sumUpFunction FuncTDataSum, TData, TDataSum
- A function that adds the first and the second argument and returns the result.
- divideFunction FuncTDataSum, Int32, TDataSum
-
A function that divides the first argument by the second argument. Calling this function
signals that the sum up is finished. Because of this extra functionality, the divide function is called even if
the divisor is 1.
Remarks The function
sumUpFunction and
divideFunction
have to work in such a way that
divideFunction(sumUpFunction(default, x), 1) == x
.
Example
For taking the linear mean, the sumUpFunction can be defined as
sumUpFunction = (sum, x) => sum + x
,
and the divideFunction as
divideFunction = (nom, denom) => nom/denom.
For taking the logarithmic mean, the sumUpFunction can be defined as
sumUpFunction = (sum, x) => sum + Math.Log(x)
,
and the
divideFunction as
divideFunction = (nom, denom) => Math.Exp(nom/denom)
.
The latter example works because the divideFunction is called in every case after summing up, even if the denominator is 1.
See Also