dtbsezxw28056 2014-02-16 14:11
浏览 73
已采纳

计数字段的反向,指数间隔表示?

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

An attribute with count of minCount has worth 1. The attribute(s) with the highest count has the lowest possible worth. The lesser used attributes are worth more - lower count -> higher worth.

The difference in worth should be exponential:

  • Commonly used attributes (high count) - smaller gap between worth
  • Uncommon attributes (low count) - larger gap between worth

I'll be using php for now, but psuedo code is equally acceptable - I'd rather just understand how to do it.

  • 写回答

1条回答 默认 最新

  • duanfu1942 2014-02-16 14:49
    关注

    So what's the problem?

    Use the following simple formula:

    currentWorth = exp(minCount / currentCount - 1)
    

    where: exp - exponent of e; currentCount - current attribute's count; minCount - least attribute's count.

    Brief explanation:

    First consider formula without exponent application:

    currentWorth = minCount / currentCount
    

    For attribute having minimal count (currentCount = minCount):

    currentWorth = minCount / minCount = 1
    

    For attributes having any other count (obviously greater than minCount):

    (currentWorth = minCount / currentCount) < 1
    

    Now let's apply exponential law:

    currentWorth = exp(minCount / currentCount - 1)
    

    For attribute having minimal count (currentCount = minCount):

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

    For attributes having any other count (currentCount > minCount):

    currentWorth = exp(minCount / currentCount - 1)
    

    Assuming:

    t = 1 - minCount / currentCount > 0
    

    We'll have:

    (currentWorth = exp(-t) = 1 / exp(t)) < 1
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 C# TCP服务端,客户端退出后,不断有数据进来
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?