use of de.lmu.ifi.dbs.elki.math.DoubleMinMax in project elki by elki-project.
the class OutlierMinusLogScaling method prepare.
@Override
public <A> void prepare(A array, NumberArrayAdapter<?, A> adapter) {
DoubleMinMax mm = new DoubleMinMax();
final int size = adapter.size(array);
for (int i = 0; i < size; i++) {
double val = adapter.getDouble(array, i);
if (!Double.isNaN(val) && !Double.isInfinite(val)) {
mm.put(val);
}
}
max = mm.getMax();
mlogmax = -FastMath.log(mm.getMin() / max);
}
use of de.lmu.ifi.dbs.elki.math.DoubleMinMax in project elki by elki-project.
the class OutlierSqrtScaling method prepare.
@Override
public void prepare(OutlierResult or) {
if (pmin == null || pmax == null) {
DoubleMinMax mm = new DoubleMinMax();
DoubleRelation scores = or.getScores();
for (DBIDIter id = scores.iterDBIDs(); id.valid(); id.advance()) {
double val = scores.doubleValue(id);
if (!Double.isInfinite(val)) {
mm.put(val);
}
}
min = (pmin == null) ? mm.getMin() : pmin;
max = (pmax == null) ? mm.getMax() : pmax;
}
factor = FastMath.sqrt(max - min);
}
use of de.lmu.ifi.dbs.elki.math.DoubleMinMax in project elki by elki-project.
the class HeDESNormalizationOutlierScaling method prepare.
@Override
public <A> void prepare(A array, NumberArrayAdapter<?, A> adapter) {
MeanVariance mv = new MeanVariance();
DoubleMinMax minmax = new DoubleMinMax();
final int size = adapter.size(array);
for (int i = 0; i < size; i++) {
double val = adapter.getDouble(array, i);
if (!Double.isNaN(val) && !Double.isInfinite(val)) {
mv.put(val);
minmax.put(val);
}
}
mean = mv.getMean();
stddev = mv.getSampleStddev();
scaledmax = getScaled(minmax.getMax());
scaledmin = getScaled(minmax.getMin());
}
use of de.lmu.ifi.dbs.elki.math.DoubleMinMax in project elki by elki-project.
the class HeDESNormalizationOutlierScaling method prepare.
@Override
public void prepare(OutlierResult or) {
MeanVariance mv = new MeanVariance();
DoubleMinMax minmax = new DoubleMinMax();
DoubleRelation scores = or.getScores();
for (DBIDIter id = scores.iterDBIDs(); id.valid(); id.advance()) {
double val = scores.doubleValue(id);
if (!Double.isNaN(val) && !Double.isInfinite(val)) {
mv.put(val);
minmax.put(val);
}
}
mean = mv.getMean();
stddev = mv.getSampleStddev();
scaledmax = getScaled(minmax.getMax());
scaledmin = getScaled(minmax.getMin());
}
use of de.lmu.ifi.dbs.elki.math.DoubleMinMax in project elki by elki-project.
the class MinusLogGammaScaling method prepare.
@Override
public void prepare(OutlierResult or) {
meta = or.getOutlierMeta();
// Determine Minimum and Maximum.
DoubleMinMax mm = new DoubleMinMax();
DoubleRelation scores = or.getScores();
for (DBIDIter id = scores.iterDBIDs(); id.valid(); id.advance()) {
double score = scores.doubleValue(id);
if (!Double.isNaN(score) && !Double.isInfinite(score)) {
mm.put(score);
}
}
max = mm.getMax();
mlogmax = -FastMath.log(mm.getMin() / max);
// with the prescaling, do Gamma Scaling.
MeanVariance mv = new MeanVariance();
for (DBIDIter id = scores.iterDBIDs(); id.valid(); id.advance()) {
double score = scores.doubleValue(id);
score = preScale(score);
if (!Double.isNaN(score) && !Double.isInfinite(score)) {
mv.put(score);
}
}
final double mean = mv.getMean();
final double var = mv.getSampleVariance();
k = (mean * mean) / var;
theta = var / mean;
atmean = GammaDistribution.regularizedGammaP(k, mean / theta);
// logger.warning("Mean:"+mean+" Var:"+var+" Theta: "+theta+" k: "+k+"
// valatmean"+atmean);
}
Aggregations