卡尔曼滤波平滑数据曲线

卡尔曼滤波可以平滑数据的曲线,在曲线检测的时候,可以作为异常点检测的算法。
https://simondlevy.github.io/ekf-tutorial/

分析一段时间内的数据的P99、P95、P75、P50、MAX、AVG, 可以很高效的祛除异常的突变点,减少数据分析过程中带来的误差问题。网上有专门的论文: DDSketch
https://github.com/DataDog/sketches-java?tab=readme-ov-file

demo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 public static void main(String[] args) {
double relativeAccuracy = 0.1;
DDSketch sketch = DDSketches.unboundedDense(relativeAccuracy);

// Adding values to the sketch
sketch.accept(3.2); // adds a single value
sketch.accept(2.1, 3); // adds multiple times the same value
DoubleStream.of(3.4, 7.6, 2.8,112,23,1,233).forEach(sketch);

final double[] valuesAtQuantiles = sketch.getValuesAtQuantiles(new double[]{1, 0.99, 0.95, 0.5, 0.1});

// Querying the sketch
final double valueAtQuantile = sketch.getValueAtQuantile(0.5);// returns the median value
final double p95Value = sketch.getValueAtQuantile(0.99);
final double p100Value = sketch.getValueAtQuantile(1);
final double minValue = sketch.getMinValue();
final double maxValue = sketch.getMaxValue();

System.out.printf("valueAtQuantile: %f, p95Value: %f, p100Value: %f, minValue: %f, maxValue: %f%n", valueAtQuantile, p95Value,p100Value, minValue, maxValue);


// Merging another sketch into the sketch, in-place
// DDSketch anotherSketch = DDSketch.unboundedDense(relativeAccuracy);
// DoubleStream.of(3.4, 7.6, 2.8).forEach(anotherSketch);
// sketch.mergeWith(anotherSketch);
}