火球法师
精华
|
战斗力 鹅
|
回帖 0
注册时间 2020-5-22
|
本帖最后由 RJG丶one 于 2024-10-16 10:40 编辑
模拟了一下,你前后两个n是一个n的话,比例大约是36.7%
- Counter({1: 36788022, 0: 36785362, 2: 26426616})
复制代码
试了假如对n个球摸2n,3n,4n……10n次的结果,基本满足半红半白是白色的2,3,4……10倍
- Counter({0: 368000, 1: 367773, 2: 264227})
- Counter({2: 594546, 1: 270555, 0: 134899})
- Counter({2: 800690, 1: 149768, 0: 49542})
- Counter({2: 908858, 1: 72765, 0: 18377})
- Counter({2: 959718, 1: 33640, 0: 6642})
- Counter({2: 982646, 1: 14902, 0: 2452})
- Counter({2: 992765, 1: 6314, 0: 921})
- Counter({2: 996917, 1: 2725, 0: 358})
- Counter({2: 998770, 1: 1105, 0: 125})
- Counter({2: 999511, 1: 424, 0: 65})
复制代码
综合来看,0的数量随摸的次数指数减小,1的数量是0的摸的次数倍。拿程序模拟了下,基本就是n个球摸n次时,1的占比最大
- from collections import Counter
- import random
- def simulate(list):
- n=len(list)
- ampier = 1.0 #改倍率
- for i in range(int(n*ampier)):
- random_num = random.randint(0,n-1)
- k = list[random_num]
- if k == 0 :list[random_num]=1
- if k == 1 :list[random_num]=2
- counter = Counter(list)
- print(counter)
- n = 1000000 #改模拟次数
- list = [0]*n
- simulate(list)
复制代码
|
|