【问题标题】:Inverse, exponentially spaced representation of a count field?计数字段的逆指数间隔表示?
【发布时间】:2014-02-16 14:11:25
【问题描述】:
var minCount = 10; // Used as 0, anything below 10 uses will be ignored

User hasMany Attributes

Attribute (id, value, count, worth)
// Count - number of users who associate with this attribute
// Worth - float 0.1 (or a better non-zero number?) to 1

计数为 minCount 的属性值为 1。 具有最高计数的属性具有最低可能的价值。 较少使用的属性价值更高 - 数量更少 -> 价值更高。

价值的差异应该是指数级的:

  • 常用属性(高计数)- 价值差距较小
  • 不常见的属性(数量少) - 价值差距较大

我现在将使用 php,但伪代码同样可以接受 - 我宁愿只是了解如何去做。

【问题讨论】:

  • 你可能想使用某种对数函数。

标签: php math exponential inverse


【解决方案1】:

那么问题出在哪里?

使用以下简单公式:

currentWorth = exp(minCount / currentCount - 1)

在哪里: exp - e 的指数; currentCount - 当前属性的计数; minCount - 最少属性计数。

简要说明:

首先考虑没有指数应用的公式:

currentWorth = minCount / currentCount

对于计数最少的属性(currentCount = minCount):

currentWorth = minCount / minCount = 1

对于具有任何其他计数(显然大于 minCount)的属性:

(currentWorth = minCount / currentCount) < 1

现在让我们应用指数定律:

currentWorth = exp(minCount / currentCount - 1)

对于计数最少的属性(currentCount = minCount):

currentWorth = exp(minCount / minCount - 1) = exp(1 - 1) = exp(0) = 1

对于具有任何其他计数的属性 (currentCount > minCount):

currentWorth = exp(minCount / currentCount - 1)

假设:

t = 1 - minCount / currentCount > 0

我们将拥有:

(currentWorth = exp(-t) = 1 / exp(t)) < 1

【讨论】:

  • 您能否简要解释一下它是如何/为什么起作用的?谢谢
  • 用 maxCount 代替 min 怎么样?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-10-14
  • 1970-01-01
  • 2022-08-17
  • 2020-02-24
  • 2014-06-10
相关资源
最近更新 更多