Commit 4ad20691 authored by Sören Henning's avatar Sören Henning

added some javadoc

parent c044bf1e
package teead.aggregation;
import teead.timeseries.TimeSeries;
public interface Aggregator {
public double aggregate(final TimeSeries timeSeries);
}
package teead.aggregation;
import teead.timeseries.TimeSeries;
/**
* A {@link Aggregator} aggregates the values of a {@link TimeSeries} (or at
* least a subset of them) to one value.
*
* Therefore classes that implement this interface have to implement the
* {@link #aggregate(TimeSeries)} method.
*
* @author Sören Henning
*
*/
public interface Aggregator {
public double aggregate(final TimeSeries timeSeries);
}
package teead.anomalyscore;
public interface AnomalyScoreCalculator {
public double calculate(final double value, final double prediction);
}
package teead.anomalyscore;
/**
* Classes that implement this interface have to implement the
* {@link #calculate(double, double)} method that calculates an anomaly score
* based on an actual and a predicted value.
*
* @author Sören Henning
*
*/
public interface AnomalyScoreCalculator {
public double calculate(final double value, final double prediction);
}
package teead.anomalyscore;
public class SimpleAnomalyScoreCalculator implements AnomalyScoreCalculator {
@Override
public double calculate(final double measurement, final double prediction) {
if (Double.isNaN(prediction) && Double.isNaN(measurement)) {
return 0.0d;
} else if (Double.isNaN(prediction) || Double.isNaN(measurement)) {
return 1.0d;
} else {
return Math.abs((prediction - measurement) / (prediction + measurement));
}
}
}
package teead.anomalyscore;
/**
* {@link AnomalyScoreCalculator} that calculates the anomaly score using the
* following formula:
*
* s = (p - m) / (p + m)
* Where m is the measurement, p is the prediction and s is the anomly score.
*
* This leads to an anomaly score that is always in the interval [0,1].
*
* This is the default anomaly score calculator in OPAD.
*
* @author Sören Henning
*
*/
public class SimpleAnomalyScoreCalculator implements AnomalyScoreCalculator {
@Override
public double calculate(final double measurement, final double prediction) {
if (Double.isNaN(prediction) && Double.isNaN(measurement)) {
return 0.0d;
} else if (Double.isNaN(prediction) || Double.isNaN(measurement)) {
return 1.0d;
} else {
return Math.abs((prediction - measurement) / (prediction + measurement));
}
}
}
package teead.timeseries;
import java.time.Instant;
public class TimeSeriesPoint {
private final Instant time;
private final double value;
public TimeSeriesPoint(final Instant time, final double value) {
this.time = time;
this.value = value;
}
public Instant getTime() {
return time;
}
public double getValue() {
return value;
}
@Override
public String toString() {
return "[" + this.time + "=" + this.value + "]";
}
}
package teead.timeseries;
import java.time.Instant;
/**
* {@link TimeSeriesPoint}s are the elements of {@link TimeSeries}. They
* consists of an instantaneous time stamp and a value.
*
* @author Sören Henning
*
*/
public class TimeSeriesPoint {
private final Instant time;
private final double value;
public TimeSeriesPoint(final Instant time, final double value) {
this.time = time;
this.value = value;
}
public Instant getTime() {
return time;
}
public double getValue() {
return value;
}
@Override
public String toString() {
return "[" + this.time + "=" + this.value + "]";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment