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());
}
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());
}
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());
}
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);
}
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());
}
}
}
Aggregations