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

« back to all changes in this revision

Viewing changes to src/de/lmu/ifi/dbs/elki/utilities/scaling/outlier/MixtureModelOutlierScalingFunction.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:
24
24
 */
25
25
 
26
26
import de.lmu.ifi.dbs.elki.database.ids.ArrayDBIDs;
27
 
import de.lmu.ifi.dbs.elki.database.ids.DBID;
28
27
import de.lmu.ifi.dbs.elki.database.ids.DBIDIter;
29
28
import de.lmu.ifi.dbs.elki.database.ids.DBIDUtil;
 
29
import de.lmu.ifi.dbs.elki.database.relation.Relation;
30
30
import de.lmu.ifi.dbs.elki.logging.Logging;
31
31
import de.lmu.ifi.dbs.elki.math.MathUtil;
32
32
import de.lmu.ifi.dbs.elki.math.MeanVariance;
44
44
  /**
45
45
   * The logger for this class.
46
46
   */
47
 
  private static final Logging logger = Logging.getLogger(MixtureModelOutlierScalingFunction.class);
 
47
  private static final Logging LOG = Logging.getLogger(MixtureModelOutlierScalingFunction.class);
48
48
  
49
49
  /**
50
50
   * Parameter mu of the gaussian distribution (outliers)
69
69
  /**
70
70
   * Precomputed static value
71
71
   */
72
 
  public final static double ONEBYSQRT2PI = 1.0 / MathUtil.SQRTTWOPI;
 
72
  public static final double ONEBYSQRT2PI = 1.0 / MathUtil.SQRTTWOPI;
73
73
 
74
74
  /**
75
75
   * Convergence parameter
121
121
  public void prepare(OutlierResult or) {
122
122
    // Initial parameters - are these defaults sounds?
123
123
    MeanVariance mv = new MeanVariance();
124
 
    for(DBIDIter iditer = or.getScores().iterDBIDs(); iditer.valid(); iditer.advance()) {
125
 
      DBID id  = iditer.getDBID();
126
 
      double val = or.getScores().get(id);
 
124
    Relation<Double> scores = or.getScores();
 
125
    for(DBIDIter id = scores.iterDBIDs(); id.valid(); id.advance()) {
 
126
      double val = scores.get(id);
127
127
      if(!Double.isNaN(val) && !Double.isInfinite(val)) {
128
128
        mv.put(val);
129
129
      }
130
130
    }
131
 
    double curMu = mv.getMean() * 2;
 
131
    double curMu = mv.getMean() * 2.;
132
132
    if(curMu == 0) {
133
133
      curMu = Double.MIN_NORMAL;
134
134
    }
159
159
        sqsum += ti * val * val; // (val - curMu) * (val - curMu);
160
160
      }
161
161
      if(tisum <= 0.0 || wsum <= 0.0) {
162
 
        logger.warning("MixtureModel Outlier Scaling converged to extreme.");
 
162
        LOG.warning("MixtureModel Outlier Scaling converged to extreme.");
163
163
        break;
164
164
      }
165
165
      double newMu = wsum / tisum;
186
186
        }
187
187
      }
188
188
      if(newSigma <= 0.0 || newAlpha <= 0.0) {
189
 
        logger.warning("MixtureModel Outlier Scaling converged to extreme.");
 
189
        LOG.warning("MixtureModel Outlier Scaling converged to extreme.");
190
190
        break;
191
191
      }
192
192
      // logger.debugFine("iter #"+iter+" mu = " + newMu + " sigma = " +
198
198
 
199
199
      iter++;
200
200
      if(iter > 100) {
201
 
        logger.warning("Max iterations met in mixture model fitting.");
 
201
        LOG.warning("Max iterations met in mixture model fitting.");
202
202
        break;
203
203
      }
204
204
    }