Package elki.data.synthetic.bymodel
Class GeneratorSingleCluster
- java.lang.Object
-
- elki.data.synthetic.bymodel.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 axisprivate double[]
clipmax
Clipping vectors.private double[]
clipmin
Clipping vectors.private double
densitycorrection
Correction factor for probability computationprivate int
dim
The dimensionalityprivate int
discarded
Discarded countprivate java.lang.String
name
Cluster nameprivate java.util.Random
random
Random generator (used for initializing random generators)private int
retries
Retry countprivate 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 generatorvoid
addTranslation(double[] v)
Add a translation to the generatordouble[]
computeMean()
Get the cluster mean vector.java.util.List<double[]>
generate(int count)
Generate a specified number of pointsdouble[]
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 factorint
getDim()
Get dimensionality of generated dataint
getDiscarded()
Get number of discarded pointsDistribution
getDistribution(int i)
Get distribution along (generator) axis i.java.lang.String
getName()
Get cluster namejava.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 transformationvoid
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
-
-
-
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.
-
trans
private AffineTransformation trans
The transformation matrix
-
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 namesize
- Cluster sizedensitycorrection
- Density correction factorrandom
- 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 generatorrnd
- 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 clippingmax
- Maximum values for clipping
-
getDim
public int getDim()
Description copied from interface:GeneratorInterface
Get dimensionality of generated data- Specified by:
getDim
in interfaceGeneratorInterface
- Returns:
- dimensionality
-
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 interfaceGeneratorInterface
- Parameters:
count
- Number of points to generate- Returns:
- List of generated points
-
getDensity
public double getDensity(double[] p)
Compute density for cluster model at given double[] p-- Specified by:
getDensity
in interfaceGeneratorInterface
- Parameters:
p
- vector- Returns:
- density
- See Also:
GeneratorInterface.getDensity(double[])
-
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 interfaceGeneratorInterface
- Returns:
- cluster size
-
getName
public java.lang.String getName()
Description copied from interface:GeneratorInterface
Get cluster name- Specified by:
getName
in interfaceGeneratorInterface
- Returns:
- cluster name
-
getDiscarded
public int getDiscarded()
Description copied from interface:GeneratorInterfaceDynamic
Get number of discarded points- Specified by:
getDiscarded
in interfaceGeneratorInterfaceDynamic
- Returns:
- number of discarded points
-
incrementDiscarded
public void incrementDiscarded()
Description copied from interface:GeneratorInterfaceDynamic
Increment the number of elements discarded.- Specified by:
incrementDiscarded
in interfaceGeneratorInterfaceDynamic
-
getRetries
public int getRetries()
Description copied from interface:GeneratorInterfaceDynamic
Retrieve remaining number of retries.- Specified by:
getRetries
in interfaceGeneratorInterfaceDynamic
- Returns:
- remaining number of retries
-
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.
-
makeModel
public Model makeModel()
Description copied from interface:GeneratorInterface
Make a cluster model for this cluster.- Specified by:
makeModel
in interfaceGeneratorInterface
- Returns:
- Cluster model
-
getDistribution
public Distribution getDistribution(int i)
Get distribution along (generator) axis i.- Parameters:
i
- Generator axis i- Returns:
- Distribution
-
computeMean
public double[] computeMean()
Description copied from interface:GeneratorInterface
Get the cluster mean vector.- Specified by:
computeMean
in interfaceGeneratorInterface
- Returns:
- Cluster mean, or
null
.
-
-