Refactor error calculation in Plot and ConfidenceIndices; update index delimiter in SimulationBuilder
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user