de.lmu.ifi.dbs.elki.data.synthetic.bymodel
Class GeneratorSingleCluster

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.data.synthetic.bymodel.GeneratorSingleCluster
All Implemented Interfaces:
GeneratorInterface, GeneratorInterfaceDynamic

public class GeneratorSingleCluster
extends 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)


Field Summary
private  LinkedList<Distribution> axes
          The distribution generators for each axis
private  Vector clipmax
           
private  Vector clipmin
          Clipping vectors.
private  double densitycorrection
          Correction factor for probability computation
private  int dim
          The dimensionality
private  int discarded
          Discarded count
private  String name
          Cluster name
 LinkedList<Vector> points
          The generated cluster points.
private  Random random
          Random generator (used for initializing random generators)
private  int retries
          Retry count
private  int size
          Number of points in the cluster (-> density)
private  AffineTransformation trans
          The transformation matrix
 
Constructor Summary
GeneratorSingleCluster(String name, int size, double densitycorrection, Random random)
          Generator (without axes)
 
Method Summary
 void addDiscarded(int discarded)
          Increase number of discarded points
 void addGenerator(Distribution gen)
          Add a new generator to the cluster.
 void addRotation(int axis1, int axis2, double angle)
          Apply a rotation to the generator
 void addTranslation(Vector v)
          Add a translation to the generator
 LinkedList<Vector> generate(int count)
          Generate the given number of additional points.
 LinkedList<Distribution> getAxes()
          Get axis generators.
 Vector getClipmax()
          Return a copy of the 'clipping maximum' vector
 Vector getClipmin()
          Return a copy of the 'clipping minimum' vector.
 double getDensity(Vector p)
          Compute density for cluster model at given vector p-
 double getDensityCorrection()
          Return density correction factor
 int getDim()
          Get the cluster dimensionality
 int getDiscarded()
          Get number of discarded points
 String getName()
          Get cluster name.
 Random getNewRandomGenerator()
          Create a new random generator (reproducible)
 LinkedList<Vector> getPoints()
          Return the list of points (no copy)
 int getRetries()
          Return number of remaining retries.
 int getSize()
          Return the size
 AffineTransformation getTrans()
          Get transformation
 void setClipping(Vector min, Vector max)
          Set a clipping box. min needs to be smaller than max in each component.
 void setDensityCorrection(double densitycorrection)
          Set density correction factor.
 void setPoints(LinkedList<Vector> points)
          Set the list of points in the cluster
private  boolean testClipping(Vector 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 LinkedList<Distribution> axes
The distribution generators for each axis


trans

private AffineTransformation trans
The transformation matrix


dim

private int dim
The dimensionality


clipmin

private Vector clipmin
Clipping vectors. Note: currently, either both or none have to be set!


clipmax

private Vector clipmax

densitycorrection

private double densitycorrection
Correction factor for probability computation


size

private int size
Number of points in the cluster (-> density)


name

private String name
Cluster name


retries

private int retries
Retry count


discarded

private int discarded
Discarded count


points

public LinkedList<Vector> points
The generated cluster points.


random

private Random random
Random generator (used for initializing random generators)

Constructor Detail

GeneratorSingleCluster

public GeneratorSingleCluster(String name,
                              int size,
                              double densitycorrection,
                              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)
                  throws UnableToComplyException
Add a new generator to the cluster. No transformations must have been added so far!

Parameters:
gen - Distribution generator
Throws:
UnableToComplyException - thrown when no new generators may be added anymore

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(Vector v)
Add a translation to the generator

Parameters:
v - translation vector

setClipping

public void setClipping(Vector min,
                        Vector max)
                 throws UnableToComplyException
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
Throws:
UnableToComplyException - thrown when invalid vectors were given.

getDim

public int getDim()
Get the cluster dimensionality

Specified by:
getDim in interface GeneratorInterface
Returns:
dimensionality

testClipping

private boolean testClipping(Vector p)
Test if a point is to be clipped

Parameters:
p - point
Returns:
true if the point is to be clipped

generate

public LinkedList<Vector> generate(int count)
                            throws UnableToComplyException
Generate the given number of additional points.

Specified by:
generate in interface GeneratorInterface
Parameters:
count - Number of points to generate
Returns:
List of generated points
Throws:
UnableToComplyException - when generation fails
See Also:
GeneratorInterface.generate(int)

getDensity

public double getDensity(Vector p)
Compute density for cluster model at given vector p-

Specified by:
getDensity in interface GeneratorInterface
Parameters:
p - vector
Returns:
density
See Also:
GeneratorInterface.getDensity(de.lmu.ifi.dbs.elki.math.linearalgebra.Vector)

getAxes

public LinkedList<Distribution> getAxes()
Get axis generators. Used for printing model information

Returns:
list of distributions

getTrans

public AffineTransformation getTrans()
Get transformation

Returns:
transformation matrix, may be null.

getClipmin

public Vector getClipmin()
Return a copy of the 'clipping minimum' vector.

Returns:
vector with lower clipping bounds. May be null.

getClipmax

public Vector getClipmax()
Return a copy of the 'clipping maximum' vector

Returns:
vector with upper clipping bounds. May be null.

getPoints

public LinkedList<Vector> getPoints()
Return the list of points (no copy)

Specified by:
getPoints in interface GeneratorInterface
Returns:
points

setPoints

public void setPoints(LinkedList<Vector> points)
Set the list of points in the cluster

Parameters:
points - New list of points in this cluster.

getSize

public int getSize()
Return the size

Specified by:
getSize in interface GeneratorInterface
Returns:
size of this cluster.

getName

public String getName()
Get cluster name.

Specified by:
getName in interface GeneratorInterface
Returns:
name of this cluster.

getDiscarded

public int getDiscarded()
Get number of discarded points

Specified by:
getDiscarded in interface GeneratorInterfaceDynamic
Returns:
number of discarded points

addDiscarded

public void addDiscarded(int discarded)
Increase number of discarded points

Specified by:
addDiscarded in interface GeneratorInterfaceDynamic
Parameters:
discarded - number of points discarded.

getRetries

public int getRetries()
Return number of remaining retries.

Specified by:
getRetries in interface GeneratorInterfaceDynamic
Returns:
Number of retries left in this cluster.

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 Random getNewRandomGenerator()
Create a new random generator (reproducible)

Returns:
new random generator derived from cluster master random.

Release 0.4.0 (2011-09-20_1324)