修改滤波器参数
This commit is contained in:
@@ -44,7 +44,7 @@ public class ApplicationConfig {
|
||||
public static final String HBASE_ZOOKEEPER_CLIENT_PORT= ConfigUtils.getStringProperty("hbase.zookeeper.client.port");
|
||||
|
||||
|
||||
public static final Double BASELINE_KALMAN_Q = ConfigUtils.getDoubleProperty("baseline.kalman.q");
|
||||
public static final Double BASELINE_KALMAN_P = ConfigUtils.getDoubleProperty("baseline.kalman.p");
|
||||
public static final Double BASELINE_KALMAN_R = ConfigUtils.getDoubleProperty("baseline.kalman.r");
|
||||
|
||||
public static final Integer LOG_WRITE_COUNT = ConfigUtils.getIntProperty("log.write.count");
|
||||
|
||||
@@ -121,7 +121,7 @@ public class BaselineGeneration {
|
||||
// 获取IP列表
|
||||
List<String> destinationIps = DruidData.getServerIpList(allFromDruid);
|
||||
ThreadFactory generationThreadFactory = new ThreadFactoryBuilder()
|
||||
.setNameFormat("baseline-load-data-%d").build();
|
||||
.setNameFormat("baseline-generate-%d").build();
|
||||
ThreadPoolExecutor generationExecutor = new ThreadPoolExecutor(
|
||||
threadNum, threadNum, 0L,
|
||||
TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), generationThreadFactory,
|
||||
|
||||
@@ -20,7 +20,6 @@ public class KalmanFilter {
|
||||
private double mdelt;
|
||||
private double Gauss;
|
||||
private double kalmanGain;
|
||||
private final static double Q = ApplicationConfig.BASELINE_KALMAN_Q;
|
||||
private final static double R = ApplicationConfig.BASELINE_KALMAN_R;
|
||||
|
||||
public KalmanFilter() {
|
||||
@@ -28,9 +27,7 @@ public class KalmanFilter {
|
||||
}
|
||||
|
||||
public void initial(){
|
||||
// TODO 调整
|
||||
pdelt = 1;
|
||||
mdelt = 1;
|
||||
pdelt = ApplicationConfig.BASELINE_KALMAN_P;
|
||||
}
|
||||
|
||||
private ArrayList<Integer> smoothSeries;
|
||||
@@ -40,20 +37,18 @@ public class KalmanFilter {
|
||||
//第一个估计值
|
||||
predict = oldValue;
|
||||
current = value;
|
||||
//高斯噪声方差
|
||||
Gauss = Math.sqrt(pdelt * pdelt + mdelt * mdelt) + Q;
|
||||
//估计方差
|
||||
kalmanGain = Math.sqrt((Gauss * Gauss)/(Gauss * Gauss + pdelt * pdelt)) + R;
|
||||
kalmanGain = pdelt/(pdelt + R);
|
||||
//估计值
|
||||
estimate = (int) (kalmanGain * (current - predict) + predict);
|
||||
//新的估计方差
|
||||
mdelt = Math.sqrt((1-kalmanGain) * Gauss * Gauss);
|
||||
mdelt = (1-kalmanGain) * pdelt ;
|
||||
|
||||
return estimate;
|
||||
}
|
||||
|
||||
|
||||
public void forcast(List<Integer> historicalSeries, Integer length){
|
||||
// 滤波
|
||||
int oldvalue = (historicalSeries.stream().mapToInt(Integer::intValue).sum())/historicalSeries.size();
|
||||
smoothSeries = new ArrayList<Integer>();
|
||||
for(int i = 0; i < historicalSeries.size(); i++){
|
||||
@@ -62,6 +57,7 @@ public class KalmanFilter {
|
||||
smoothSeries.add(oldvalue);
|
||||
}
|
||||
|
||||
// 平均
|
||||
forecastSeries = new ArrayList<>();
|
||||
Integer partitonNum = historicalSeries.size()/length;
|
||||
for(int i = 0; i<length; i++){
|
||||
|
||||
@@ -49,8 +49,8 @@ baseline.historical.ratio.threshold=0.1
|
||||
baseline.historical.sparse.fill.percentile=0.95
|
||||
baseline.rational.percentile=0.95
|
||||
#Kalman Filter
|
||||
baseline.kalman.q=0.000001
|
||||
baseline.kalman.r=0.002
|
||||
baseline.kalman.p=0.000001
|
||||
baseline.kalman.r=4
|
||||
|
||||
|
||||
# 每更新1000个记录打印log
|
||||
|
||||
Reference in New Issue
Block a user