Class GeneratorSingleCluster

  • All Implemented Interfaces:
    GeneratorInterface, GeneratorInterfaceDynamic

    public class GeneratorSingleCluster
    extends java.lang.Object
    implements GeneratorInterfaceDynamic
    Class to generate a single cluster according to a model as well as getting the density of a given model at that point (to evaluate generated points according to the same model)
    Since:
    0.2
    Author:
    Erich Schubert
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<Distribution> axes
      The distribution generators for each axis
      private double[] clipmax
      Clipping vectors.
      private double[] clipmin
      Clipping vectors.
      private double densitycorrection
      Correction factor for probability computation
      private int dim
      The dimensionality
      private int discarded
      Discarded count
      private java.lang.String name
      Cluster name
      private java.util.Random random
      Random generator (used for initializing random generators)
      private int retries
      Retry count
      private java.util.List<java.util.Random> rnds
      The random generators for each axis.
      private int size
      Number of points in the cluster (~density)
      private AffineTransformation trans
      The transformation matrix
    • Constructor Summary

      Constructors 
      Constructor Description
      GeneratorSingleCluster​(java.lang.String name, int size, double densitycorrection, java.util.Random random)
      Generator (without axes)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addGenerator​(Distribution gen, java.util.Random rnd)
      Add a new generator to the cluster.
      void addRotation​(int axis1, int axis2, double angle)
      Apply a rotation to the generator
      void addTranslation​(double[] v)
      Add a translation to the generator
      double[] computeMean()
      Get the cluster mean vector.
      java.util.List<double[]> generate​(int count)
      Generate a specified number of points
      double[] getClipmax()
      Return a copy of the 'clipping maximum' double[]
      double[] getClipmin()
      Return a copy of the 'clipping minimum' double[].
      double getDensity​(double[] p)
      Compute density for cluster model at given double[] p-
      double getDensityCorrection()
      Return density correction factor
      int getDim()
      Get dimensionality of generated data
      int getDiscarded()
      Get number of discarded points
      Distribution getDistribution​(int i)
      Get distribution along (generator) axis i.
      java.lang.String getName()
      Get cluster name
      java.util.Random getNewRandomGenerator()
      Create a new random generator (reproducible)
      int getRetries()
      Retrieve remaining number of retries.
      int getSize()
      Get number of points to be generated by this generator.
      AffineTransformation getTransformation()
      Get transformation
      void incrementDiscarded()
      Increment the number of elements discarded.
      Model makeModel()
      Make a cluster model for this cluster.
      void setClipping​(double[] min, double[] max)
      Set a clipping box. min needs to be smaller than max in each component.
      void setDensityCorrection​(double densitycorrection)
      Set density correction factor.
      private boolean testClipping​(double[] p)
      Test if a point is to be clipped
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • axes

        private java.util.List<Distribution> axes
        The distribution generators for each axis
      • rnds

        private java.util.List<java.util.Random> rnds
        The random generators for each axis.
      • dim

        private int dim
        The dimensionality
      • clipmin

        private double[] clipmin
        Clipping vectors. Note: currently, either both or none have to be set!
      • clipmax

        private double[] clipmax
        Clipping vectors. Note: currently, either both or none have to be set!
      • densitycorrection

        private double densitycorrection
        Correction factor for probability computation
      • size

        private int size
        Number of points in the cluster (~density)
      • name

        private java.lang.String name
        Cluster name
      • retries

        private int retries
        Retry count
      • discarded

        private int discarded
        Discarded count
      • random

        private java.util.Random random
        Random generator (used for initializing random generators)
    • Constructor Detail

      • GeneratorSingleCluster

        public GeneratorSingleCluster​(java.lang.String name,
                                      int size,
                                      double densitycorrection,
                                      java.util.Random random)
        Generator (without axes)
        Parameters:
        name - Cluster name
        size - Cluster size
        densitycorrection - Density correction factor
        random - Random number generator
    • Method Detail

      • addGenerator

        public void addGenerator​(Distribution gen,
                                 java.util.Random rnd)
        Add a new generator to the cluster. No transformations must have been added so far!
        Parameters:
        gen - Distribution generator
        rnd - Random sources
      • addRotation

        public void addRotation​(int axis1,
                                int axis2,
                                double angle)
        Apply a rotation to the generator
        Parameters:
        axis1 - First axis (0 <= axis1 < dim)
        axis2 - Second axis (0 <= axis2 < dim)
        angle - Angle in Radians
      • addTranslation

        public void addTranslation​(double[] v)
        Add a translation to the generator
        Parameters:
        v - translation double[]
      • setClipping

        public void setClipping​(double[] min,
                                double[] max)
        Set a clipping box. min needs to be smaller than max in each component. Note: Clippings are not 'modified' by translation / rotation / transformation operations.
        Parameters:
        min - Minimum values for clipping
        max - Maximum values for clipping
      • testClipping

        private boolean testClipping​(double[] p)
        Test if a point is to be clipped
        Parameters:
        p - point
        Returns:
        true if the point is to be clipped
      • generate

        public java.util.List<double[]> generate​(int count)
        Description copied from interface: GeneratorInterface
        Generate a specified number of points
        Specified by:
        generate in interface GeneratorInterface
        Parameters:
        count - Number of points to generate
        Returns:
        List of generated points
      • getTransformation

        public AffineTransformation getTransformation()
        Get transformation
        Returns:
        transformation matrix, may be null.
      • getClipmin

        public double[] getClipmin()
        Return a copy of the 'clipping minimum' double[].
        Returns:
        double[] with lower clipping bounds. May be null.
      • getClipmax

        public double[] getClipmax()
        Return a copy of the 'clipping maximum' double[]
        Returns:
        double[] with upper clipping bounds. May be null.
      • getSize

        public int getSize()
        Description copied from interface: GeneratorInterface
        Get number of points to be generated by this generator.
        Specified by:
        getSize in interface GeneratorInterface
        Returns:
        cluster size
      • getDensityCorrection

        public double getDensityCorrection()
        Return density correction factor
        Returns:
        density correction factor
      • setDensityCorrection

        public void setDensityCorrection​(double densitycorrection)
        Set density correction factor.
        Parameters:
        densitycorrection - new density correction factor.
      • getNewRandomGenerator

        public java.util.Random getNewRandomGenerator()
        Create a new random generator (reproducible)
        Returns:
        new random generator derived from cluster master random.
      • getDistribution

        public Distribution getDistribution​(int i)
        Get distribution along (generator) axis i.
        Parameters:
        i - Generator axis i
        Returns:
        Distribution