Search in sources :

Example 1 with SobolSequenceGenerator

use of org.apache.commons.math3.random.SobolSequenceGenerator in project GDSC-SMLM by aherbert.

the class CreateData method createUniformDistribution.

/**
	 * Create distribution within an XY border
	 * 
	 * @param border
	 * @return
	 */
private UniformDistribution createUniformDistribution(double border) {
    double depth = (settings.fixedDepth) ? settings.depth / settings.pixelPitch : settings.depth / (2 * settings.pixelPitch);
    // Ensure the focal plane is in the middle of the zDepth
    double[] max = new double[] { settings.size / 2 - border, settings.size / 2 - border, depth };
    double[] min = new double[3];
    for (int i = 0; i < 3; i++) min[i] = -max[i];
    if (settings.fixedDepth)
        min[2] = max[2];
    // Try using different distributions:
    final RandomGenerator rand1 = createRandomGenerator();
    if (settings.distribution.equals(DISTRIBUTION[UNIFORM_HALTON])) {
        return new UniformDistribution(min, max, rand1.nextInt());
    }
    if (settings.distribution.equals(DISTRIBUTION[UNIFORM_SOBOL])) {
        SobolSequenceGenerator rvg = new SobolSequenceGenerator(3);
        rvg.skipTo(rand1.nextInt());
        return new UniformDistribution(min, max, rvg);
    }
    // Create a distribution using random generators for each dimension 
    UniformDistribution distribution = new UniformDistribution(min, max, this);
    return distribution;
}
Also used : UniformDistribution(gdsc.smlm.model.UniformDistribution) SobolSequenceGenerator(org.apache.commons.math3.random.SobolSequenceGenerator) RandomGenerator(org.apache.commons.math3.random.RandomGenerator)

Aggregations

UniformDistribution (gdsc.smlm.model.UniformDistribution)1 RandomGenerator (org.apache.commons.math3.random.RandomGenerator)1 SobolSequenceGenerator (org.apache.commons.math3.random.SobolSequenceGenerator)1