基本概念
mean(平均值
)
均值是就全部數據計算的,它具有優良的數學性質,是實際中應用最廣泛的集中趨勢測度值.其主要缺點是易受數據極端值的影響,對于偏態分布的數據,均值的代表性較差.作為均值變形的調和平均數和幾何平均數,是適用于特殊數據的代表值,調和平均數主要用于不能直接計算均值的數據,幾何平均數則主要用于計算比率數據的平均數,這兩個測度值與均值一樣易受極端值的影響.
median(中位數
)
中位數是一組數據中間位置上的代表值.其特點是不受數據極端值的影響.對于具有偏態分布的數據,中位數的代表性要比均值好.
在一組排好序數據中,數據數量為奇數,則中值為中間的那個數。 如果數據數量為偶數,則中值為中間的那兩個數值的平均值。
percentile(百分位數
)
第p百分位數是這樣一個值,它使得至少有p%的數據項小于或等于這個值,且至少有(100-p)%的數據項大于或等于這個值。
4類Reservoir
ExponentiallyDecayingReservoir(指數采樣
)
An exponentially-decaying random reservoir of {@code long}s. Uses Cormode et al's forward-decaying priority reservoir sampling method to produce a statistically representative sampling reservoir, exponentially biased towards newer entries.
UniformReservoir(隨機采樣
)
A random sampling reservoir of a stream of {@code long}s. Uses Vitter's Algorithm R to produce a statistically representative sample.
SlidingWindowReservoir(只存最近N條數據
)
A {@link Reservoir} implementation backed by a sliding window that stores the last {@code N}
- measurements.
SlidingTimeWindowReservoir(指定時間窗口重置數據
)
A {@link Reservoir} implementation backed by a sliding window that stores only the measurements made
小結
關于瞬時值
除了SlidingTimeWindowReservoir外,其余的都不能直接反映瞬時值,都是被“平均”了。假設一開始有個值,后續都為0,那么他們都會只體現初始值,體現不出后續變為0的情況,只有后續該值繼續有變動,才會“延遲”體現出來。
關于snapshot
snapshot的percentile默認有75thPercentile、95thPercentile、98thPercentile、99thPercentile、999thPercentile。
- 其中95+的指標能較明顯體現極值的變動
- 75thPercentile則相對比較平緩
在極值變動小的情況下,SlidingTimeWindowReservoir會更貼近實際情況,其中時間窗口跟上報interval對應上即可。即使極值變動大,相比其他幾個Reservoir,SlidingTimeWindowReservoir還是比較接近實際數據,曲線會有明顯變動,不像其他的一段時間可能都是平滑的。