use of org.apache.commons.math3.stat.descriptive.summary.Sum in project repseqio by repseqio.
the class ExportCloneSequencesActionTest method randomRoundTest.
@Test
public void randomRoundTest() throws Exception {
double value = 12.34;
double sum = 0.0;
RandomGenerator random = new Well19937c(1232434);
for (int i = 0; i < 100000; i++) sum += ExportCloneSequencesAction.randomizedRound(value, random);
assertEquals(value, sum / 100000, 0.1);
}
use of org.apache.commons.math3.stat.descriptive.summary.Sum in project opennars by opennars.
the class HyperassociativeMap method align.
public void align() {
// refresh all nodes
/*
if (!coordinates.keySet().equals(graph.vertexSet())) {
final Map<N, ArrayRealVector> newCoordinates = new HashMap<N, ArrayRealVector>();
for (final N node : graph.vertexSet()) {
if (coordinates.containsKey(node)) {
newCoordinates.put(node, coordinates.get(node));
} else {
newCoordinates.put(node, randomCoordinates(dimensions));
}
}
coordinates = Collections.synchronizedMap(newCoordinates);
}
*/
totalMovement = DEFAULT_TOTAL_MOVEMENT;
maxMovement = DEFAULT_MAX_MOVEMENT;
ArrayRealVector center;
if (threadExecutor == null) {
center = processLocally();
} else {
// align all nodes in parallel
final List<Future<ArrayRealVector>> futures = submitFutureAligns();
// all the points
try {
center = waitAndProcessFutures(futures);
} catch (InterruptedException caught) {
// LOGGER.warn("waitAndProcessFutures was unexpectedly interrupted", caught);
throw new RuntimeException("Unexpected interruption. Get should block indefinitely", caught);
}
}
// LOGGER.debug("maxMove: " + maxMovement + ", Average Move: " + getAverageMovement());
// divide each coordinate of the sum of all the points by the number of
// nodes in order to calculate the average point, or center of all the
// points
int numVertices = graph.vertexSet().size();
center.mapDivideToSelf(numVertices);
recenterNodes(center);
}
Aggregations