题目是文绉绉的说法,背景来于群里提问,是一份文件里面关于最高投标限价的确定。

最高投标限价下浮率在开标前在开标现场采取逐标段摇珠方式确定,摇珠操作办法如下:在下浮率摇珠范围内,以0.1%为以一档次增序确定摇珠号码,不少于31个球,每个标段各一次性摇取3个球(摇出的球不放回),摇出3个球对应的下浮率的平均值即为本标段的下浮率(注:下浮率的平均值四舍五入取整到0.001%)

最高评标限价=最高投标限价 x (1 - 下浮率)

用简单粗暴的数学应用题来描述,就是

1到31中依次不放回挑三个数字,这三个数字的平均值为a,我要从1到31中选一个数字,这个数字高于a百分1的话扣1.5分,低百分1的话就扣0.5分,问选择哪个数字扣分最少的概率最大?

我用了随机抽取和平均值判断的方法来计算

import random
s = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]

def choose(s,no):
    #挑选三个数字
    dic = {}
    c = random.sample(s,3)
    ave = (c[0]+c[1]+c[2])/3
    a = random.sample(c,1)
    a = float(a[0])
    if a > ave:
        score = ((((a - ave)/ave)*100)//1)*1.5
    else:
        score = ((((ave - a)/ave)*100)//1)*0.5
    dic[no] = [a,score]
    return dic
flag = 1000000
record = {}
no = 0
while flag:
    k = choose(s,no)
    record.update(k)
    flag = flag - 1
    no += 1
r = list(record.values())#如果按照平均值来算
final={}
for i in s:
    count = 0
    sumary = 0
    for choice in r:
        if choice[0] == i:
            sumary += choice[1]
            count += 1
    if count!= 0:
        final[i] = sumary/count
    else:
        final[i] = 0

j = list(final.items())
j.sort(key = lambda x:x[1],reverse=True)

print(j)

100万次投掷结果

[(31, 83.82834638329605), (30, 79.52800049531004), (29, 76.17331441402108), (28, 71.87696804726407), (27, 68.18778308238463), (26, 64.67018198786748), (25, 60.67964184142264), (24, 56.45526274996125), (23, 52.392923563325276), (22, 48.68755592582308), (21, 44.58517213672044), (1, 44.5334890483851), (20, 40.74669140383426), (2, 39.63405063685342), (19, 37.418869140804865), (3, 35.294571004085675), (18, 33.83776818704008), (4, 31.641003948110548), (17, 31.04532411835488), (5, 28.63851921274602), (16, 28.615155057839036), (6, 26.1258323267986), (15, 25.99136919466403), (14, 24.509914748774317), (7, 24.21303671437461), (13, 23.11067443437519), (8, 22.75180413169387), (12, 22.04871418304534), (9, 21.76769120800572), (11, 21.743313360924084), (10, 21.466741230931742)]

01-21 12:50