# 随机机制的探索（RandomPicker中文文档）

RandomPicker?? 最初的灵感来来自音乐随机播放： 权重++ 切歌模式

### 暴击机制与翻牌随机

1.通过重置随机率来避免真空期；2.这个综合概率是可以算出来的。

### 概率推算

!!!真tm美妙的数学，目前还没有公式能表示 1+1/2+1/3+...+1/n ，看来只能写个脚本算出前54张的对应概率了。 Python代码如下：

```def poker(n):
rate = 0
for x in range(1,n+1):
rate = rate + 1/x
return (1/n) * rate

for x in range(1,55):
print("%d: %.2f" % (x, poker(x)*100) + "%")```

### 概率校验

```    private void pokerTest(int num) {
List<Integer> list = new ArrayList<>();
for (int x = 0; x < num; x++)
Collections.shuffle(list);

Random random = new Random();
int luckyCount = 0;
for (int i = 0; i < 10_000; i++) {
int index = random.nextInt(list.size());
int lucky = list.remove(index);
if (lucky == num/2) { //取中间值作为中奖数
luckyCount++;
//抽中后重新洗牌
list.clear();
for (int x = 0; x < num; x++)
Collections.shuffle(list);
}
}
System.out.println(" " + (luckyCount/10_000f));
}```

### 公式校准

n张牌，1/n第1次中，1/n第2次中，1/n第三次中...1/n第n次中。综合=(2/(n * (n+1)) * 1/n + (2 * 2/(n * (n+1)) * 1/(n * 2) + ... + (n * 2/(n * (n+1)) * 1/(n * n) = (2/(n * (n+1)) * (1+1+1+...+1) = 2/(n + 1)

```def poker(n):
return 2/(n+1)

for x in range(1,55):
print("%d: %.2f" % (x, poker(x)*100) + "%")```

P=2/(n+1) 1: 100.00% 2: 66.67% 3: 50.00% 4: 40.00% 5: 33.33% 6: 28.57% 7: 25.00% 8: 22.22% 9: 20.00% 10: 18.18% 11: 16.67% 12: 15.38% 13: 14.29% 14: 13.33% 15: 12.50% 16: 11.76% 17: 11.11% 18: 10.53% 19: 10.00% 20: 9.52% 21: 9.09% 22: 8.70% 23: 8.33% 24: 8.00% 25: 7.69% 26: 7.41% 27: 7.14% 28: 6.90% 29: 6.67% 30: 6.45% 31: 6.25% 32: 6.06% 33: 5.88% 34: 5.71% 35: 5.56% 36: 5.41% 37: 5.26% 38: 5.13% 39: 5.00% 40: 4.88% 41: 4.76% 42: 4.65% 43: 4.55% 44: 4.44% 45: 4.35% 46: 4.26% 47: 4.17% 48: 4.08% 49: 4.00% 50: 3.92% 51: 3.85% 52: 3.77% 53: 3.70% 54: 3.64%

22 篇文章12 人订阅

0 条评论

## 相关文章

8217

1486

3243

911

2945

### 电商评论情感分析

? 随着网上购物的流行,各大电商竞争激烈,为了提高客户服务质量,除了打价格战外,了解客户的需求点,倾听客户的心声也越来越重要,其中重要的方式 就是对消费者的文...

9437

1.6K6

3298

67110

51412