Class SphericalKMeansPlusPlus.Instance

  • Enclosing class:
    SphericalKMeansPlusPlus<O>

    protected static class SphericalKMeansPlusPlus.Instance
    extends java.lang.Object
    Abstract instance implementing the weight handling.
    Author:
    Erich Schubert
    • Field Detail

      • alpha

        protected double alpha
        Parameter to balance distance vs. uniform sampling.
      • diststat

        protected long diststat
        Count the number of distance computations.
      • random

        protected java.util.Random random
        Random generator
    • Constructor Detail

      • Instance

        public Instance​(Relation<? extends NumberVector> relation,
                        double alpha,
                        RandomFactory rnd)
        Constructor.
        Parameters:
        relation - Data relation
        alpha - Alpha parameter
        rnd - Random generator
    • Method Detail

      • run

        public double[][] run​(int k)
        Run k-means++ initialization for number vectors.
        Parameters:
        k - K
        Returns:
        Vectors
      • similarity

        protected double similarity​(NumberVector a,
                                    DBIDRef b)
        Compute the distance of two objects.
        Parameters:
        a - First object
        b - Second object
        Returns:
        Distance
      • chooseRemaining

        protected void chooseRemaining​(int k,
                                       java.util.List<NumberVector> means,
                                       double weightsum)
        Choose remaining means, weighted by distance.
        Parameters:
        k - Number of means to choose
        means - Means storage
        weightsum - Sum of weights
      • initialWeights

        protected double initialWeights​(NumberVector first)
        Initialize the weight list.
        Parameters:
        first - Added ID
        Returns:
        Weight sum
      • updateWeights

        protected double updateWeights​(NumberVector latest)
        Update the weight list.
        Parameters:
        latest - Added ID
        Returns:
        Weight sum
      • nextDouble

        protected double nextDouble​(double weightsum)