關(guān)于codahale的HistogramMetric

基本概念

mean(平均值)

均值是就全部數(shù)據(jù)計算的,它具有優(yōu)良的數(shù)學(xué)性質(zhì),是實際中應(yīng)用最廣泛的集中趨勢測度值.其主要缺點是易受數(shù)據(jù)極端值的影響,對于偏態(tài)分布的數(shù)據(jù),均值的代表性較差.作為均值變形的調(diào)和平均數(shù)和幾何平均數(shù),是適用于特殊數(shù)據(jù)的代表值,調(diào)和平均數(shù)主要用于不能直接計算均值的數(shù)據(jù),幾何平均數(shù)則主要用于計算比率數(shù)據(jù)的平均數(shù),這兩個測度值與均值一樣易受極端值的影響.

median(中位數(shù))

中位數(shù)是一組數(shù)據(jù)中間位置上的代表值.其特點是不受數(shù)據(jù)極端值的影響.對于具有偏態(tài)分布的數(shù)據(jù),中位數(shù)的代表性要比均值好.
在一組排好序數(shù)據(jù)中,數(shù)據(jù)數(shù)量為奇數(shù),則中值為中間的那個數(shù)。 如果數(shù)據(jù)數(shù)量為偶數(shù),則中值為中間的那兩個數(shù)值的平均值。

percentile(百分位數(shù))

第p百分位數(shù)是這樣一個值,它使得至少有p%的數(shù)據(jù)項小于或等于這個值,且至少有(100-p)%的數(shù)據(jù)項大于或等于這個值。

4類Reservoir

ExponentiallyDecayingReservoir(指數(shù)采樣)

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條數(shù)據(jù))

A {@link Reservoir} implementation backed by a sliding window that stores the last {@code N}

  • measurements.

SlidingTimeWindowReservoir(指定時間窗口重置數(shù)據(jù))

A {@link Reservoir} implementation backed by a sliding window that stores only the measurements made

小結(jié)

關(guān)于瞬時值

除了SlidingTimeWindowReservoir外,其余的都不能直接反映瞬時值,都是被“平均”了。假設(shè)一開始有個值,后續(xù)都為0,那么他們都會只體現(xiàn)初始值,體現(xiàn)不出后續(xù)變?yōu)?的情況,只有后續(xù)該值繼續(xù)有變動,才會“延遲”體現(xiàn)出來。

關(guān)于snapshot

snapshot的percentile默認有75thPercentile、95thPercentile、98thPercentile、99thPercentile、999thPercentile。

  • 其中95+的指標(biāo)能較明顯體現(xiàn)極值的變動
  • 75thPercentile則相對比較平緩
    在極值變動小的情況下,SlidingTimeWindowReservoir會更貼近實際情況,其中時間窗口跟上報interval對應(yīng)上即可。即使極值變動大,相比其他幾個Reservoir,SlidingTimeWindowReservoir還是比較接近實際數(shù)據(jù),曲線會有明顯變動,不像其他的一段時間可能都是平滑的。

doc

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容