@Override public EigenvalueTableModel getEigenvalueTableModel() { double varianceSum = 0.0d; for (Eigenvector wv : eigenVectors) { varianceSum += wv.getEigenvalue(); } return new EigenvalueTableModel(eigenVectors, cumulativeVariance, varianceSum); }
@Override public double[] getCumulativeVariance() { double[] cumulativeVariance = new double[attributeNames.length]; double varianceSum = 0.0d; int i = 0; for (Eigenvector wv : eigenVectors) { varianceSum += wv.getEigenvalue(); cumulativeVariance[i++] = varianceSum; } return cumulativeVariance; }
/** Calculates the cumulative variance. */ private void calculateCumulativeVariance() { double sumvariance = 0.0d; for (Eigenvector ev : this.eigenVectors) { sumvariance += ev.getEigenvalue(); } this.variances = new double[this.eigenVectors.size()]; this.cumulativeVariance = new double[variances.length]; double cumulative = 0.0d; int counter = 0; for (Eigenvector ev : this.eigenVectors) { double proportion = ev.getEigenvalue() / sumvariance; this.variances[counter] = proportion; cumulative += proportion; this.cumulativeVariance[counter] = cumulative; counter++; } }