Search in sources :

Example 1 with Distribution

use of de.lmu.ifi.dbs.elki.math.statistics.distribution.Distribution in project elki by elki-project.

the class BestFitEstimatorTest method testNaN.

@Test(expected = ArithmeticException.class)
public void testNaN() {
    BestFitEstimator est = init();
    Distribution edist = est.estimate(new double[] { Double.NaN }, DoubleArrayAdapter.STATIC);
    assertEquals("Wrong class of distribution", UniformDistribution.class, edist.getClass());
}
Also used : UniformDistribution(de.lmu.ifi.dbs.elki.math.statistics.distribution.UniformDistribution) Distribution(de.lmu.ifi.dbs.elki.math.statistics.distribution.Distribution) NormalDistribution(de.lmu.ifi.dbs.elki.math.statistics.distribution.NormalDistribution) Test(org.junit.Test)

Example 2 with Distribution

use of de.lmu.ifi.dbs.elki.math.statistics.distribution.Distribution in project elki by elki-project.

the class BestFitEstimatorTest method testEmpty.

@Test(expected = ArithmeticException.class)
public void testEmpty() {
    BestFitEstimator est = init();
    Distribution edist = est.estimate(new double[0], DoubleArrayAdapter.STATIC);
    assertEquals("Wrong class of distribution", UniformDistribution.class, edist.getClass());
}
Also used : UniformDistribution(de.lmu.ifi.dbs.elki.math.statistics.distribution.UniformDistribution) Distribution(de.lmu.ifi.dbs.elki.math.statistics.distribution.Distribution) NormalDistribution(de.lmu.ifi.dbs.elki.math.statistics.distribution.NormalDistribution) Test(org.junit.Test)

Example 3 with Distribution

use of de.lmu.ifi.dbs.elki.math.statistics.distribution.Distribution in project elki by elki-project.

the class BestFitEstimatorTest method testConstant.

@Test
public void testConstant() {
    BestFitEstimator est = init();
    Distribution edist = est.estimate(new double[100], DoubleArrayAdapter.STATIC);
    assertEquals("Wrong class of distribution", UniformDistribution.class, edist.getClass());
}
Also used : UniformDistribution(de.lmu.ifi.dbs.elki.math.statistics.distribution.UniformDistribution) Distribution(de.lmu.ifi.dbs.elki.math.statistics.distribution.Distribution) NormalDistribution(de.lmu.ifi.dbs.elki.math.statistics.distribution.NormalDistribution) Test(org.junit.Test)

Example 4 with Distribution

use of de.lmu.ifi.dbs.elki.math.statistics.distribution.Distribution in project elki by elki-project.

the class BestFitEstimatorTest method testNormalDistribution.

@Test
public void testNormalDistribution() {
    BestFitEstimator est = init();
    Random r = new Random(0L);
    double[] data = new double[10000];
    for (int i = 0; i < data.length; i++) {
        data[i] = 2 + 3 * r.nextGaussian();
    }
    Distribution edist = est.estimate(data, DoubleArrayAdapter.STATIC);
    assertEquals("Wrong class of distribution", NormalDistribution.class, edist.getClass());
    NormalDistribution good = (NormalDistribution) edist;
    assertEquals("Mean not as expected from trimmed estimator.", 2., good.getMean(), 2e-2);
    assertEquals("Stddev not as expected from trimmed estimator.", 3., good.getStddev(), 4e-2);
}
Also used : Random(java.util.Random) NormalDistribution(de.lmu.ifi.dbs.elki.math.statistics.distribution.NormalDistribution) UniformDistribution(de.lmu.ifi.dbs.elki.math.statistics.distribution.UniformDistribution) Distribution(de.lmu.ifi.dbs.elki.math.statistics.distribution.Distribution) NormalDistribution(de.lmu.ifi.dbs.elki.math.statistics.distribution.NormalDistribution) Test(org.junit.Test)

Example 5 with Distribution

use of de.lmu.ifi.dbs.elki.math.statistics.distribution.Distribution in project elki by elki-project.

the class GeneratorXMLDatabaseConnection method processElementNormal.

/**
 * Process a 'normal' Element in the XML stream.
 *
 * @param cluster
 * @param cur Current document nod
 */
private void processElementNormal(GeneratorSingleCluster cluster, Node cur) {
    double mean = 0.0;
    double stddev = 1.0;
    String meanstr = ((Element) cur).getAttribute(ATTR_MEAN);
    if (meanstr != null && meanstr.length() > 0) {
        mean = ParseUtil.parseDouble(meanstr);
    }
    String stddevstr = ((Element) cur).getAttribute(ATTR_STDDEV);
    if (stddevstr != null && stddevstr.length() > 0) {
        stddev = ParseUtil.parseDouble(stddevstr);
    }
    // *** New normal distribution generator
    Random random = cluster.getNewRandomGenerator();
    Distribution generator = new NormalDistribution(mean, stddev, random);
    cluster.addGenerator(generator);
    // TODO: check for unknown attributes.
    XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild());
    while (iter.hasNext()) {
        Node child = iter.next();
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            LOG.warning("Unknown element in XML specification file: " + child.getNodeName());
        }
    }
}
Also used : Random(java.util.Random) NormalDistribution(de.lmu.ifi.dbs.elki.math.statistics.distribution.NormalDistribution) Element(org.w3c.dom.Element) Distribution(de.lmu.ifi.dbs.elki.math.statistics.distribution.Distribution) NormalDistribution(de.lmu.ifi.dbs.elki.math.statistics.distribution.NormalDistribution) UniformDistribution(de.lmu.ifi.dbs.elki.math.statistics.distribution.UniformDistribution) GammaDistribution(de.lmu.ifi.dbs.elki.math.statistics.distribution.GammaDistribution) HaltonUniformDistribution(de.lmu.ifi.dbs.elki.math.statistics.distribution.HaltonUniformDistribution) Node(org.w3c.dom.Node) XMLNodeIterator(de.lmu.ifi.dbs.elki.utilities.xml.XMLNodeIterator)

Aggregations

Distribution (de.lmu.ifi.dbs.elki.math.statistics.distribution.Distribution)15 UniformDistribution (de.lmu.ifi.dbs.elki.math.statistics.distribution.UniformDistribution)12 NormalDistribution (de.lmu.ifi.dbs.elki.math.statistics.distribution.NormalDistribution)11 Test (org.junit.Test)6 Random (java.util.Random)5 GammaDistribution (de.lmu.ifi.dbs.elki.math.statistics.distribution.GammaDistribution)4 HaltonUniformDistribution (de.lmu.ifi.dbs.elki.math.statistics.distribution.HaltonUniformDistribution)4 XMLNodeIterator (de.lmu.ifi.dbs.elki.utilities.xml.XMLNodeIterator)4 Element (org.w3c.dom.Element)4 Node (org.w3c.dom.Node)4 ArrayList (java.util.ArrayList)3 Model (de.lmu.ifi.dbs.elki.data.model.Model)2 GeneratorSingleCluster (de.lmu.ifi.dbs.elki.data.synthetic.bymodel.GeneratorSingleCluster)2 SimpleTypeInformation (de.lmu.ifi.dbs.elki.data.type.SimpleTypeInformation)2 VectorFieldTypeInformation (de.lmu.ifi.dbs.elki.data.type.VectorFieldTypeInformation)2 AbortException (de.lmu.ifi.dbs.elki.utilities.exceptions.AbortException)2 List (java.util.List)2 WritableDoubleDataStore (de.lmu.ifi.dbs.elki.database.datastore.WritableDoubleDataStore)1 DBIDIter (de.lmu.ifi.dbs.elki.database.ids.DBIDIter)1 DoubleRelation (de.lmu.ifi.dbs.elki.database.relation.DoubleRelation)1