~ubuntu-branches/ubuntu/vivid/elki/vivid

« back to all changes in this revision

Viewing changes to src/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/SignificantEigenPairFilter.java

  • Committer: Package Import Robot
  • Author(s): Erich Schubert
  • Date: 2012-12-14 20:45:15 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20121214204515-4m0d0er9ivtu5w9d
Tags: 0.5.5-1
New upstream release: 0.5.5 interim release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
    double maxContrast = 0.0;
88
88
    // calc the eigenvalue sum.
89
89
    double eigenValueSum = 0.0;
90
 
    for(int i = 0; i < eigenPairs.size(); i++) {
 
90
    for (int i = 0; i < eigenPairs.size(); i++) {
91
91
      EigenPair eigenPair = eigenPairs.getEigenPair(i);
92
92
      eigenValueSum += eigenPair.getEigenvalue();
93
93
    }
94
94
    double weakEigenvalue = eigenValueSum / eigenPairs.size() * walpha;
95
95
    // now find the maximum contrast.
96
96
    double currSum = eigenPairs.getEigenPair(eigenPairs.size() - 1).getEigenvalue();
97
 
    for(int i = eigenPairs.size() - 2; i >= 0; i--) {
 
97
    for (int i = eigenPairs.size() - 2; i >= 0; i--) {
98
98
      EigenPair eigenPair = eigenPairs.getEigenPair(i);
99
99
      currSum += eigenPair.getEigenvalue();
100
100
      // weak?
101
 
      if(eigenPair.getEigenvalue() < weakEigenvalue) {
 
101
      if (eigenPair.getEigenvalue() < weakEigenvalue) {
102
102
        continue;
103
103
      }
104
104
      double contrast = eigenPair.getEigenvalue() / (currSum / (eigenPairs.size() - i));
105
 
      if(contrast > maxContrast) {
 
105
      if (contrast > maxContrast) {
106
106
        maxContrast = contrast;
107
107
        contrastMaximum = i;
108
108
      }
109
109
    }
110
110
 
111
 
    for(int i = 0; i <= contrastMaximum /* && i < eigenPairs.size() */; i++) {
 
111
    for (int i = 0; i <= contrastMaximum /* && i < eigenPairs.size() */; i++) {
112
112
      EigenPair eigenPair = eigenPairs.getEigenPair(i);
113
113
      strongEigenPairs.add(eigenPair);
114
114
    }
115
 
    for(int i = contrastMaximum + 1; i < eigenPairs.size(); i++) {
 
115
    for (int i = contrastMaximum + 1; i < eigenPairs.size(); i++) {
116
116
      EigenPair eigenPair = eigenPairs.getEigenPair(i);
117
117
      weakEigenPairs.add(eigenPair);
118
118
    }
133
133
    @Override
134
134
    protected void makeOptions(Parameterization config) {
135
135
      super.makeOptions(config);
136
 
      DoubleParameter walphaP = new DoubleParameter(WeakEigenPairFilter.EIGENPAIR_FILTER_WALPHA, new GreaterEqualConstraint(0.0), DEFAULT_WALPHA);
137
 
      if(config.grab(walphaP)) {
 
136
      DoubleParameter walphaP = new DoubleParameter(WeakEigenPairFilter.EIGENPAIR_FILTER_WALPHA, DEFAULT_WALPHA);
 
137
      walphaP.addConstraint(new GreaterEqualConstraint(0.0));
 
138
      if (config.grab(walphaP)) {
138
139
        walpha = walphaP.getValue();
139
140
      }
140
141
    }
144
145
      return new SignificantEigenPairFilter(walpha);
145
146
    }
146
147
  }
147
 
}
 
 
b'\\ No newline at end of file'
 
148
}