histogram.percentileCI(percentile[, options])


  • percentile <number> 百分位值,范围在 (0, 100]。
  • options <Object>
    • confidence <number> 区间的置信水平,在 0 和 1 之间(不包括0和1)。默认值:0.95。
  • 返回:<Object>
    • value <number> 点估计(同 histogram.percentile())。
    • lower <number> 置信区间的下界
    • upper <number> 置信区间的上限。

使用精确二项式方法返回给定百分位数的置信区间。样本越少,区间越宽,反映出百分位数估计的不确定性越大。至少需要记录 2 个值;如果少于 2 个,lower 和 upper 将等于 value。

🌐 Returns a confidence interval for the given percentile using the exact binomial method. With fewer samples, the interval will be wider, reflecting the greater uncertainty in the percentile estimate. Requires at least 2 recorded values; with fewer than 2, lower and upper will equal value.

const { createHistogram } = require('node:perf_hooks');

const h = createHistogram();
for (let i = 0; i < 1000; i++) {
  h.record(Math.floor(Math.random() * 100));
}

const ci = h.percentileCI(99);
console.log(ci.value);  // The p99 point estimate
console.log(ci.lower);  // The lower bound (95% confidence)
console.log(ci.upper);  // The upper bound (95% confidence)