|
|
@@ -41,9 +41,18 @@ public class TrendAnalysis {
|
|
|
public static void analysisDetail(StopVO vo, List<Integer> times) {
|
|
|
// 计算线性回归斜率
|
|
|
double slope = calculateSlope(times);
|
|
|
-
|
|
|
// 计算标准差
|
|
|
double stdDev = calculateStandardDeviation(times);
|
|
|
+ // 计算平均值
|
|
|
+ double mean = times.stream().mapToInt(Integer::intValue).average().orElse(0);
|
|
|
+ // 计算变异系数
|
|
|
+ double coefficientOfVariation = mean != 0 ? stdDev / mean : 0;
|
|
|
+
|
|
|
+ // 定义阈值
|
|
|
+ // 5%的平均值作为斜率阈值
|
|
|
+ double slopeThreshold = Math.abs(mean * 0.05);
|
|
|
+ // 变异系数阈值
|
|
|
+ double cvThreshold = 0.1;
|
|
|
|
|
|
// 判断趋势类型
|
|
|
String trend = determineTrend(slope, stdDev, times);
|
|
|
@@ -51,8 +60,15 @@ public class TrendAnalysis {
|
|
|
vo.setStdDev(stdDev);
|
|
|
vo.setResult(trend);
|
|
|
vo.setDataNum(times.size());
|
|
|
+ // 添加平均值和变异系数到vo中
|
|
|
+ vo.setMean(mean);
|
|
|
+ vo.setCoefficientOfVariation(coefficientOfVariation);
|
|
|
+ // 添加阈值到vo中
|
|
|
+ vo.setSlopeThreshold(slopeThreshold);
|
|
|
+ vo.setCvThreshold(cvThreshold);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 批量趋势分析并返回统计结果
|
|
|
*
|
|
|
@@ -181,4 +197,4 @@ public class TrendAnalysis {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+}
|