【问题标题】:Why use 0.5 as the parameter of Poisson distribution in ConcurrentHashMap?为什么在 ConcurrentHashMap 中使用 0.5 作为泊松分布的参数?
【发布时间】:2019-03-20 03:48:28
【问题描述】:

根据 ConcurrentHashMap 中的 java 文档:

 * Ideally, the frequency of nodes in bins follows a Poisson distribution
 * (http://en.wikipedia.org/wiki/Poisson_distribution) with a
 * parameter of about 0.5 on average, given the resizing threshold
 * of 0.75, although with a large variance because of resizing
 * granularity. Ignoring variance, the expected occurrences of
 * list size k are (exp(-0.5) * pow(0.5, k) / factorial(k)). The
 * first values are:

问题是:0.5这个参数是怎么来的?

【问题讨论】:

  • 我没有这方面的资料,但我确实记得在某处读过它基本上是根据经验观察到的运行的猜测。我猜他们有一堆 CHM 的示例用例,他们认为这些用例很好地代表了“典型”使用,玩弄了一些数字,发现 0.5 似乎效果很好。
  • @yshavit 我想我明白了:看我的答案

标签: java concurrenthashmap


【解决方案1】:

我想我得到了 0.5 的原因: 最大元素计数为0.75 * bin[].length,然后将调整 bin 的大小。 因此假设元素计数为:0.5 * bin[].length,则每个 bin 的平均元素计数为 0.5。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-17
    • 2022-01-10
    • 2018-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多