Refactor error calculation in Plot and ConfidenceIndices; update index delimiter in SimulationBuilder

This commit is contained in:
2025-06-16 17:43:22 +02:00
parent 846b33ad43
commit 9c5f7d01e8
4 changed files with 5 additions and 5 deletions

View File

@@ -144,8 +144,7 @@ public class Plot {
var model = this.statList.getModel();
var avg = summary.average;
var err = summary.calcError(0.95)
.apply(val -> val / 2); // Done to get the error for the mean value
var err = summary.calcError(0.95);
for (int i = 0; i < model.getSize(); i++) {
var entry = model.getElementAt(i);

View File

@@ -201,7 +201,7 @@ public class SimulationBuilder {
if (indices == null)
return this;
for (var index : indices.split(",")) {
for (var index : indices.split(";")) {
var parts = index.split("=");
if (parts.length != 2)
throw new IllegalArgumentException("Invalid confidence index: " + index);

View File

@@ -138,7 +138,7 @@ public class ConfidenceIndices {
for (var stat : statistics) {
var err = error.of(stat);
if (!Double.isFinite(err))
if (!Double.isFinite(err) || err == 0.0d)
continue;
retValues.add("%s:%s=%.3f".formatted(this.nodes[i], stat, err));

View File

@@ -298,7 +298,8 @@ public class NodeStats implements Cloneable, Iterable<Double> {
public NodeStats calcError(NodeStats alpha) {
var n = this.stats.size();
var distr = new TDistribution(null, n - 1);
var tValue = alpha.clone().apply(a -> distr.inverseCumulativeProbability(a));
var prob = alpha.clone().apply(a -> 1 - (1 - a) / 2.0d);
var tValue = prob.apply(p -> distr.inverseCumulativeProbability(p));
return this.stdDev().merge(tValue, (std, t) -> t * (std / Math.sqrt(n)));
}