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>axesThe distribution generators for each axisprivate double[]clipmaxClipping vectors.private double[]clipminClipping vectors.private doubledensitycorrectionCorrection factor for probability computationprivate intdimThe dimensionalityprivate intdiscardedDiscarded countprivate java.lang.StringnameCluster nameprivate java.util.RandomrandomRandom generator (used for initializing random generators)private intretriesRetry countprivate java.util.List<java.util.Random>rndsThe random generators for each axis.private intsizeNumber of points in the cluster (~density)private AffineTransformationtransThe 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 voidaddGenerator(Distribution gen, java.util.Random rnd)Add a new generator to the cluster.voidaddRotation(int axis1, int axis2, double angle)Apply a rotation to the generatorvoidaddTranslation(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[].doublegetDensity(double[] p)Compute density for cluster model at given double[] p-doublegetDensityCorrection()Return density correction factorintgetDim()Get dimensionality of generated dataintgetDiscarded()Get number of discarded pointsDistributiongetDistribution(int i)Get distribution along (generator) axis i.java.lang.StringgetName()Get cluster namejava.util.RandomgetNewRandomGenerator()Create a new random generator (reproducible)intgetRetries()Retrieve remaining number of retries.intgetSize()Get number of points to be generated by this generator.AffineTransformationgetTransformation()Get transformationvoidincrementDiscarded()Increment the number of elements discarded.ModelmakeModel()Make a cluster model for this cluster.voidsetClipping(double[] min, double[] max)Set a clipping box. min needs to be smaller than max in each component.voidsetDensityCorrection(double densitycorrection)Set density correction factor.private booleantestClipping(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:GeneratorInterfaceGet dimensionality of generated data- Specified by:
getDimin 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:GeneratorInterfaceGenerate a specified number of points- Specified by:
generatein 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:
getDensityin 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:GeneratorInterfaceGet number of points to be generated by this generator.- Specified by:
getSizein interfaceGeneratorInterface- Returns:
- cluster size
-
getName
public java.lang.String getName()
Description copied from interface:GeneratorInterfaceGet cluster name- Specified by:
getNamein interfaceGeneratorInterface- Returns:
- cluster name
-
getDiscarded
public int getDiscarded()
Description copied from interface:GeneratorInterfaceDynamicGet number of discarded points- Specified by:
getDiscardedin interfaceGeneratorInterfaceDynamic- Returns:
- number of discarded points
-
incrementDiscarded
public void incrementDiscarded()
Description copied from interface:GeneratorInterfaceDynamicIncrement the number of elements discarded.- Specified by:
incrementDiscardedin interfaceGeneratorInterfaceDynamic
-
getRetries
public int getRetries()
Description copied from interface:GeneratorInterfaceDynamicRetrieve remaining number of retries.- Specified by:
getRetriesin 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:GeneratorInterfaceMake a cluster model for this cluster.- Specified by:
makeModelin 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:GeneratorInterfaceGet the cluster mean vector.- Specified by:
computeMeanin interfaceGeneratorInterface- Returns:
- Cluster mean, or
null.
-
-