weightedAverage static method
Calculate weighted average confidence.
Implementation
static double weightedAverage(List<double> scores, List<double> weights) {
if (scores.isEmpty || scores.length != weights.length) return 0.0;
double sum = 0.0;
double weightSum = 0.0;
for (int i = 0; i < scores.length; i++) {
sum += scores[i] * weights[i];
weightSum += weights[i];
}
return weightSum > 0 ? sum / weightSum : 0.0;
}