Example usage for org.apache.commons.math3.distribution MixtureMultivariateNormalDistribution MixtureMultivariateNormalDistribution

List of usage examples for org.apache.commons.math3.distribution MixtureMultivariateNormalDistribution MixtureMultivariateNormalDistribution

Introduction

In this page you can find the example usage for org.apache.commons.math3.distribution MixtureMultivariateNormalDistribution MixtureMultivariateNormalDistribution.

Prototype

public MixtureMultivariateNormalDistribution(RandomGenerator rng,
        List<Pair<Double, MultivariateNormalDistribution>> components)
        throws NotPositiveException, DimensionMismatchException 

Source Link

Document

Creates a mixture model from a list of distributions and their associated weights.

Usage

From source file:rndvecgen.RandomVecGen.java

private void init() throws Exception {
    DocVector.initVectorRange(prop);/* www .  j  av  a 2 s. com*/

    numPoints = Integer.parseInt(prop.getProperty("syntheticdata.numsamples"));
    numGaussians = Integer.parseInt(prop.getProperty("syntheticdata.numgaussians"));
    maxSpan = Integer.parseInt(prop.getProperty("syntheticdata.maxSpan"));
    diagonalCovMatrix = Boolean.parseBoolean(prop.getProperty("syntheticdata.diagonalcov"));

    min = Float.parseFloat(prop.getProperty("syntheticdata.min"));
    max = Float.parseFloat(prop.getProperty("syntheticdata.max"));

    numDimensions = Integer.parseInt(prop.getProperty("vec.numdimensions"));

    final int NUM_MU_GEN = 5;
    float delta = (max - min) / NUM_MU_GEN;
    muGen = new NormalDistribution[NUM_MU_GEN];
    for (int i = 0; i < NUM_MU_GEN; i++) {
        muGen[i] = new NormalDistribution(min + i * delta, Math.random() * maxSpan);
    }

    List<Pair<Double, MultivariateNormalDistribution>> components = new ArrayList<>();
    for (int i = 0; i < numGaussians; i++) {
        components.add(new Pair(new Double(1 / (double) numGaussians), genRandom(i)));
    }

    // Ensure that we can reproduce the results...
    RandomGenerator rg = new JDKRandomGenerator();
    rg.setSeed(SEED);
    this.mixtureDist = new MixtureMultivariateNormalDistribution(rg, components);
}