use of org.apache.commons.math3.random.RandomVectorGenerator in project GDSC-SMLM by aherbert.
the class SearchSpace method sampleWithoutRounding.
private static double[][] sampleWithoutRounding(int samples, RandomVectorGenerator[] generator, final int[] indices, int size, final double[] centre, final double[] lower, final double[] range) {
RandomVectorGenerator g = createGenerator(generator, size);
// Generate random points
final double[][] searchSpace = new double[samples][];
for (int i = 0; i < samples; i++) {
final double[] r = g.nextVector();
final double[] p = centre.clone();
for (int j = 0; j < size; j++) {
// Ensure the min interval is respected
p[indices[j]] = lower[j] + r[j] * range[j];
}
searchSpace[i] = p;
}
return searchSpace;
}
use of org.apache.commons.math3.random.RandomVectorGenerator in project GDSC-SMLM by aherbert.
the class SearchSpace method sampleWithRounding.
/**
* Sample with rounding. The input dimensions are used purely for rounding. The limits of the range have been
* precomputed.
*
* @param samples
* the samples
* @param generator
* the generator
* @param indices
* the indices
* @param dimensions
* the dimensions
* @param size
* the size
* @param centre
* the centre
* @param lower
* the lower
* @param range
* the range
* @return the sample
*/
private static double[][] sampleWithRounding(int samples, RandomVectorGenerator[] generator, final int[] indices, final Dimension[] dimensions, int size, final double[] centre, final double[] lower, final double[] range) {
RandomVectorGenerator g = createGenerator(generator, size);
// Generate random points
final double[][] searchSpace = new double[samples][];
for (int i = 0; i < samples; i++) {
final double[] r = g.nextVector();
final double[] p = centre.clone();
for (int j = 0; j < size; j++) {
// Ensure the min interval is respected
p[indices[j]] = dimensions[j].round(lower[j] + r[j] * range[j]);
}
searchSpace[i] = p;
}
return searchSpace;
}
Aggregations