掷硬币选择策略
下面的问题以前讨论过么?有的话请来个链接:loveliness: ,没有的话大家可以看看:lol 。上周在x上很火很多人都无法理解答案的问题。掷硬币100 次——给出了一系列正面 (H) 和反面 (T)。
现在你有选择权,可以选择积分规则。
规则A:对于序列中的每个HH,你会都会得到一分;对于每个HT,对手都会得一分。
规则B:反过来,对于序列中的每个HH,对手会都会得到一分;对于每个HT,则你得一分。
比如说HHHT,按A规则你得2分,对手1分。
问:为了积分最高你应该选择哪条规则?又或者说,它们的获胜概率是一样的?
规则有点不清楚,是只有分数比对手高就赢,还是分数尽量高? mathe 发表于 2024-3-20 11:08
规则有点不清楚,是只有分数比对手高就赢,还是分数尽量高?
哦,我昨天没理解你的意思。现在想明白了。追求的是胜利的场次,比如玩这个游戏100轮(每轮投100次),胜出数更多的那个策略。不是单次胜负里,有可能使积分最高的策略。
为了追求胜利的概率最大,答案是选B。
我把这个问题还转载在煎蛋网:https://jandan.net/p/115970#/
有网友提供了模拟代码,https://codepen.io/lunar-dark/pen/NWmpKpM
每次扔100个币,连续扔100k次,HH胜45k左右,HT胜48k左右
本帖最后由 BeerRabbit 于 2024-3-21 21:26 编辑
扔n次硬币,在所有可能的序列(共有2^n个)中,满足“其所包含的(10)组个数大于(11)组个数”的序列个数为A(n)。
则A(n)(n=1~15)的前几个数字为:
{0, 1, 3, 6, 13, 28, 56, 113, 231, 464, 930, 1875, 3766, 7547, 15151}
如果把规则描述中的“大于”改成“小于”和“等于”则对应的结果分别是——
小于:
{0, 1, 2, 4, 10, 21, 42, 89, 184, 371, 758, 1546, 3122, 6315, 12782}
等于:
{2, 2, 3, 6, 9, 15, 30, 54, 97, 189, 360, 675, 1304, 2522, 4835}
其中只有“等于”对应的数列在OEIS上能查到(A163493)
补一个MMA代码:
F := Module[{Y, a, b},
Y = X[[# ;; # + 1]] & /@ Range;
a = Select // Length;
b = Select // Length;
If]
];
Table & /@ (IntegerDigits[# - 1, 2, n] & /@ Range) // Count[#, 1] &, {n, 1, 15}]
Table & /@ (IntegerDigits[# - 1, 2, n] & /@ Range) // Count[#, -1] &, {n, 1, 15}]
Table & /@ (IntegerDigits[# - 1, 2, n] & /@ Range) // Count[#, 0] &, {n, 1, 15}]
设n个硬币的所有排列中,HH比HT多s个的方案中最后一个为HEAD的计数为count[ s ],
最后一个为TAIL的计数为count[ s ]
那么我们有
//count + TAIL => count
//count + HEAD => count
//count + TAIL => count
//count + HEAD => count
就可以递归计算了,最后我们分别对s<0,s>0和所有s情况进行统计,就可以得到规则A结果如下
Level 2{-:1; +:1; T:4}
Lost Ratio: 0.250000000; Win Ratio: 0.250000000
Level 3{-:3; +:2; T:8}
Lost Ratio: 0.375000000; Win Ratio: 0.250000000
Level 4{-:6; +:4; T:16}
Lost Ratio: 0.375000000; Win Ratio: 0.250000000
Level 5{-:13; +:10; T:32}
Lost Ratio: 0.406250000; Win Ratio: 0.312500000
Level 6{-:28; +:21; T:64}
Lost Ratio: 0.437500000; Win Ratio: 0.328125000
Level 7{-:56; +:42; T:128}
Lost Ratio: 0.437500000; Win Ratio: 0.328125000
Level 8{-:113; +:89; T:256}
Lost Ratio: 0.441406250; Win Ratio: 0.347656250
Level 9{-:231; +:184; T:512}
Lost Ratio: 0.451171875; Win Ratio: 0.359375000
Level 10{-:464; +:371; T:1024}
Lost Ratio: 0.453125000; Win Ratio: 0.362304688
Level 11{-:930; +:758; T:2048}
Lost Ratio: 0.454101562; Win Ratio: 0.370117188
Level 12{-:1875; +:1546; T:4096}
Lost Ratio: 0.457763672; Win Ratio: 0.377441406
Level 13{-:3766; +:3122; T:8192}
Lost Ratio: 0.459716797; Win Ratio: 0.381103516
Level 14{-:7547; +:6315; T:16384}
Lost Ratio: 0.460632324; Win Ratio: 0.385437012
Level 15{-:15151; +:12782; T:32768}
Lost Ratio: 0.462371826; Win Ratio: 0.390075684
Level 16{-:30398; +:25780; T:65536}
Lost Ratio: 0.463836670; Win Ratio: 0.393371582
Level 17{-:60917; +:51962; T:131072}
Lost Ratio: 0.464759827; Win Ratio: 0.396438599
Level 18{-:122116; +:104759; T:262144}
Lost Ratio: 0.465835571; Win Ratio: 0.399623871
Level 19{-:244786; +:210934; T:524288}
Lost Ratio: 0.466892242; Win Ratio: 0.402324677
Level 20{-:490435; +:424404; T:1048576}
Lost Ratio: 0.467715263; Win Ratio: 0.404743195
Level 21{-:982544; +:853806; T:2097152}
Lost Ratio: 0.468513489; Win Ratio: 0.407126427
Level 22{-:1968413; +:1716759; T:4194304}
Lost Ratio: 0.469306231; Win Ratio: 0.409307241
Level 23{-:3942649; +:3450158; T:8388608}
Lost Ratio: 0.470000386; Win Ratio: 0.411290884
Level 24{-:7896116; +:6932169; T:16777216}
Lost Ratio: 0.470645189; Win Ratio: 0.413189471
Level 25{-:15813268; +:13924260; T:33554432}
Lost Ratio: 0.471272111; Win Ratio: 0.414975286
Level 26{-:31665423; +:27959805; T:67108864}
Lost Ratio: 0.471851572; Win Ratio: 0.416633561
Level 27{-:63403245; +:56130762; T:134217728}
Lost Ratio: 0.472390987; Win Ratio: 0.418206766
Level 28{-:126945244; +:112662414; T:268435456}
Lost Ratio: 0.472907886; Win Ratio: 0.419700198
Level 29{-:254152625; +:226080318; T:536870912}
Lost Ratio: 0.473396154; Win Ratio: 0.421107408
Level 30{-:508798604; +:453595341; T:1073741824}
Lost Ratio: 0.473855626; Win Ratio: 0.422443581
Level 31{-:1018538560; +:909925794; T:2147483648}
Lost Ratio: 0.474293977; Win Ratio: 0.423717217
Level 32{-:2038870881; +:1825052601; T:4294967296}
Lost Ratio: 0.474711620; Win Ratio: 0.424928172
Level 33{-:4081149015; +:3660020992; T:8589934592}
Lost Ratio: 0.475108276; Win Ratio: 0.426082522
Level 34{-:8168806568; +:7339006091; T:17179869184}
Lost Ratio: 0.475487123; Win Ratio: 0.427186378
Level 35{-:16350068706; +:14714278862; T:34359738368}
Lost Ratio: 0.475849628; Win Ratio: 0.428241877
Level 36{-:32723948523; +:29497991764; T:68719476736}
Lost Ratio: 0.476196125; Win Ratio: 0.429252276
Level 37{-:65493519976; +:59129191502; T:137438953472}
Lost Ratio: 0.476528075; Win Ratio: 0.430221491
Level 38{-:131074624997; +:118514143839; T:274877906944}
Lost Ratio: 0.476846708; Win Ratio: 0.431151944
Level 39{-:262317425785; +:237519754398; T:549755813888}
Lost Ratio: 0.477152618; Win Ratio: 0.432045916
Level 40{-:524958142500; +:475985181699; T:1099511627776}
Lost Ratio: 0.477446649; Win Ratio: 0.432906001
Level 41{-:1050538666974; +:953791746232; T:2199023255552}
Lost Ratio: 0.477729676; Win Ratio: 0.433734270
Level 42{-:2102276334809; +:1911094220329; T:4398046511104}
Lost Ratio: 0.478002297; Win Ratio: 0.434532517
Level 43{-:4206864396623; +:3828962014178; T:8796093022208}
Lost Ratio: 0.478265110; Win Ratio: 0.435302583
Level 44{-:8418190639762; +:7671004379270; T:17592186044416}
Lost Ratio: 0.478518737; Win Ratio: 0.436046115
Level 45{-:16844999783923; +:15367286674854; T:35184372088832}
Lost Ratio: 0.478763689; Win Ratio: 0.436764557
Level 46{-:33706658979762; +:30783461520417; T:70368744177664}
Lost Ratio: 0.479000434; Win Ratio: 0.437459299
Level 47{-:67445546718318; +:61661546052970; T:140737488355328}
Lost Ratio: 0.479229433; Win Ratio: 0.438131636
Level 48{-:134953487689979; +:123506359586330; T:281474976710656}
Lost Ratio: 0.479451102; Win Ratio: 0.438782733
Level 49{-:270027848607006; +:247367912956234; T:562949953421312}
Lost Ratio: 0.479665816; Win Ratio: 0.439413684
Level 50{-:540290017770539; +:495424686385921; T:1125899906842624}
Lost Ratio: 0.479873934; Win Ratio: 0.440025515
Level 51{-:1081034575458005; +:992186165234042; T:2251799813685248}
Lost Ratio: 0.480075790; Win Ratio: 0.440619170
Level 52{-:2162951403461284; +:1986968023977076; T:4503599627370496}
Lost Ratio: 0.480271690; Win Ratio: 0.441195530
Level 53{-:4327616247886287; +:3978979098703842; T:9007199254740992}
Lost Ratio: 0.480461920; Win Ratio: 0.441755421
Level 54{-:8658562105558546; +:7967761493171689; T:18014398509481984}
Lost Ratio: 0.480646750; Win Ratio: 0.442299613
Level 55{-:17323597897095126; +:15954589880068658; T:36028797018963968}
Lost Ratio: 0.480826431; Win Ratio: 0.442828826
Level 56{-:34659789001937499; +:31946282845475983; T:72057594037927936}
Lost Ratio: 0.481001197; Win Ratio: 0.443343735
Level 57{-:69344087881466419; +:63964801743634604; T:144115188075855872}
Lost Ratio: 0.481171269; Win Ratio: 0.443844973
Level 58{-:138735901938024056; +:128070306599995123; T:288230376151711744}
Lost Ratio: 0.481336852; Win Ratio: 0.444333135
Level 59{-:277564780813682810; +:256414803751661558; T:576460752303423488}
Lost Ratio: 0.481498141; Win Ratio: 0.444808780
Level 60{-:555310775241402235; +:513364164018228986; T:1152921504606846976}
Lost Ratio: 0.481655319; Win Ratio: 0.445272434
Level 61{-:1110974893383673726; +:1027770934429489042; T:2305843009213693952}
Lost Ratio: 0.481808557; Win Ratio: 0.445724592
Level 62{-:2222639050259509267; +:2057576223894455283; T:4611686018427387904}
Lost Ratio: 0.481958017; Win Ratio: 0.446165722
Level 63{-:4446623192062333919; +:4119123512725195326; T:9223372036854775808}
Lost Ratio: 0.482103853; Win Ratio: 0.446596266
Level 64{-:8895872357517637214; +:8246001554861115252; T:18446744073709551616}
Lost Ratio: 0.482246207; Win Ratio: 0.447016640
Level 65{-:17796873271053029653; +:16507151512508666042; T:36893488147419103232}
Lost Ratio: 0.482385217; Win Ratio: 0.447427238
Level 66{-:35603766388874739620; +:33043906056811623823; T:73786976294838206464}
Lost Ratio: 0.482521011; Win Ratio: 0.447828434
Level 67{-:71227115962775090666; +:66145682802046447046; T:147573952589676412928}
Lost Ratio: 0.482653712; Win Ratio: 0.448220581
Level 68{-:142492519428947769307; +:132404535159512224412; T:295147905179352825856}
Lost Ratio: 0.482783435; Win Ratio: 0.448604015
Level 69{-:285059920909917280960; +:265030453542522009918; T:590295810358705651712}
Lost Ratio: 0.482910290; Win Ratio: 0.448979052
Level 70{-:570266342991310380669; +:530494118345662224495; T:1180591620717411303424}
Lost Ratio: 0.483034381; Win Ratio: 0.449345997
Level 71{-:1140819396071763147249; +:1061836226580767416414; T:2361183241434822606848}
Lost Ratio: 0.483155808; Win Ratio: 0.449705134
Level 72{-:2282200071943826876012; +:2125332856811397927619; T:4722366482869645213696}
Lost Ratio: 0.483274663; Win Ratio: 0.450056738
Level 73{-:4565499267737216265302; +:4253917822433577627128; T:9444732965739290427392}
Lost Ratio: 0.483391038; Win Ratio: 0.450401069
Level 74{-:9133151520435651789217; +:8514207139227413146745; T:18889465931478580854784}
Lost Ratio: 0.483505016; Win Ratio: 0.450738373
Level 75{-:18270521550270342212311; +:17040900728868720133282; T:37778931862957161709568}
Lost Ratio: 0.483616679; Win Ratio: 0.451068887
Level 76{-:36549311041555539630538; +:34106278272314587246334; T:75557863725914323419136}
Lost Ratio: 0.483726104; Win Ratio: 0.451392834
Level 77{-:73114830956673371034931; +:68260550426788450056342; T:151115727451828646838272}
Lost Ratio: 0.483833365; Win Ratio: 0.451710431
Level 78{-:146261446921943725859682; +:136615231045505248590849; T:302231454903657293676544}
Lost Ratio: 0.483938533; Win Ratio: 0.452021882
Level 79{-:292585239027218816407710; +:273415125650727515981898; T:604462909807314587353088}
Lost Ratio: 0.484041674; Win Ratio: 0.452327382
Level 80{-:585292796430823286927275; +:547192610993271223091380; T:1208925819614629174706176}
Lost Ratio: 0.484142854; Win Ratio: 0.452627119
Level 81{-:1170825634177077110870280; +:1095096439280899592527454; T:2417851639229258349412352}
Lost Ratio: 0.484242133; Win Ratio: 0.452921272
Level 82{-:2342122444333080831069525; +:2191589137328140534359061; T:4835703278458516698824704}
Lost Ratio: 0.484339570; Win Ratio: 0.453210011
Level 83{-:4685169971453576402114239; +:4385920026959752499395522; T:9671406556917033397649408}
Lost Ratio: 0.484435221; Win Ratio: 0.453493502
Level 84{-:9372156612423209494930690; +:8777225067884161265859068; T:19342813113834066795298816}
Lost Ratio: 0.484529140; Win Ratio: 0.453771901
Level 85{-:18747881569295018566227193; +:17565029010192229555683562; T:38685626227668133590597632}
Lost Ratio: 0.484621380; Win Ratio: 0.454045358
Level 86{-:37502773668565344580054000; +:35150844640588479920099541; T:77371252455336267181195264}
Lost Ratio: 0.484711989; Win Ratio: 0.454314019
Level 87{-:75019323427359402521240804; +:70342541716306389892694826; T:154742504910672534362390528}
Lost Ratio: 0.484801015; Win Ratio: 0.454578021
Level 88{-:150065723199619521733844549; +:140765387879978358194901747; T:309485009821345068724781056}
Lost Ratio: 0.484888503; Win Ratio: 0.454837499
Level 89{-:300184674501703905185838253; +:281688662926108928889257276; T:618970019642690137449562112}
Lost Ratio: 0.484974498; Win Ratio: 0.455092580
Level 90{-:600474008067095161152981134; +:563687808773224635460498999; T:1237940039285380274899124224}
Lost Ratio: 0.485059041; Win Ratio: 0.455343386
Level 91{-:1201153839991509749206642088; +:1127986292896084679593168094; T:2475880078570760549798248448}
Lost Ratio: 0.485142172; Win Ratio: 0.455590036
Level 92{-:2402712531475335480184774453; +:2257173917801257953591374762; T:4951760157141521099596496896}
Lost Ratio: 0.485223932; Win Ratio: 0.455832643
Level 93{-:4806221543467443573003097204; +:4516711544274268550994147514; T:9903520314283042199192993792}
Lost Ratio: 0.485304356; Win Ratio: 0.456071316
Level 94{-:9614010315089867177184044101; +:9038074678253724183092135879; T:19807040628566084398385987584}
Lost Ratio: 0.485383480; Win Ratio: 0.456306161
Level 95{-:19231104991729941404294079361; +:18085304892440684110986199974; T:39614081257132168796771975168}
Lost Ratio: 0.485461341; Win Ratio: 0.456537280
Level 96{-:38468281157842911503464095780; +:36188633299318103514887654313; T:79228162514264337593543950336}
Lost Ratio: 0.485537970; Win Ratio: 0.456764768
Level 97{-:76948514655739529604967508868; +:72412753410981598089324159996; T:158456325028528675187087900672}
Lost Ratio: 0.485613399; Win Ratio: 0.456988722
Level 98{-:153920563783770743671444551799; +:144895388740592532690382440637; T:316912650057057350374175801344}
Lost Ratio: 0.485687661; Win Ratio: 0.457209230
Level 99{-:307887475013879139393113690181; +:289928413318724861004451642914; T:633825300114114700748351602688}
Lost Ratio: 0.485760784; Win Ratio: 0.457426381
Level 100{-:615866238418960422359689555420; +:580127949239420834381088427404; T:1267650600228229401496703205376}
Lost Ratio: 0.485832798; Win Ratio: 0.457640259
而对于长度为100,方案A的各种得分差分布为
count[-50]=1
count[-49]=1325
count[-48]=294050
count[-47]=26617290
count[-46]=1330255815
count[-45]=42919935835
count[-44]=983156559210
count[-43]=17033316749820
count[-42]=233400608147735
count[-41]=2614381239414735
count[-40]=24550574713787010
count[-39]=197150946519643550
count[-38]=1375679410685414450
count[-37]=8451073972164127108
count[-36]=46210399961145343413
count[-35]=227004362149489184022
count[-34]=1009860516432421484187
count[-33]=4096712177858121360399
count[-32]=15247749308938974542421
count[-31]=52350824044788156054216
count[-30]=166607171077709190756060
count[-29]=493645720376366009163516
count[-28]=1367143433188619109053352
count[-27]=3551954012109459164577376
count[-26]=8686109884277283187997106
count[-25]=20055225149893348816333554
count[-24]=43844627549786945958589680
count[-23]=91001422499460503626585260
count[-22]=179763829541066577971612952
count[-21]=338757354861894875655388932
count[-20]=610315290987050592852426198
count[-19]=1053386609896119310058220228
count[-18]=1745118407135736558029089726
count[-17]=2780043435628079169902430486
count[-16]=4265870818552696769971996446
count[-15]=6315241299298077313067374248
count[-14]=9033468660829178932648222012
count[-13]=12503156034451523603337781244
count[-12]=16767474523347110492502105992
count[-11]=21814598828347171620337357152
count[-10]=27566098692592563661052910714
count[-9]=33871849156423377148712374730
count[-8]=40513231768576837533202703640
count[-7]=47215173793461455702590625004
count[-6]=53666145312218517883076816204
count[-5]=59543892735365660957139789376
count[-4]=64543704258920714616943515626
count[-3]=68405570616760641713507980732
count[-2]=70936793516426715075493432331
count[-1]=72027343751505931141583428951
count=71656412569848144755925222552
count=69889902879368773013173398330
count=66869833498941600008977020285
count=62797584077826886590138297533
count=57913469629702003919294540728
count=52475267875032276436535696432
count=46738074687809409100604254222
count=40937334350174219405131043774
count=35276210892780037700873584024
count=29917762478918476882474277364
count=24981757635389467855166986572
count=20545499627554709440186102728
count=16647734116451790331493872286
count=13294601803478278796908527364
count=10466633422619434205715329714
count=8125926604510988498320158730
count=6222846658893522578565699494
count=4701814476526100204432324608
count=3505952179066875448077681428
count=2580529813081249595335291068
count=1875284165409224711691937404
count=1345762480733919638881619816
count=953884541799647548467422492
count=667924788912881555961042316
count=462101645635764580234757556
count=315933195502895341298309504
count=213484478528509628644574020
count=142597606903299702697618140
count=94165295328566214405929076
count=61483190066811250498536216
count=39697162852338816024840079
count=25348214742043061522139419
count=16008996325093659482849398
count=10001161522302185560020758
count=6180791128771176344008963
count=3779023811996709991594019
count=2286066208917365558991896
count=1368359999967026032354752
count=810476154998045342538654
count=475041466638122452084414
count=275546274649221072591904
count=158178293697206665493492
count=89867648637382149651024
count=50533126782451168142548
count=28123845113051129416418
count=15491932054735130750508
count=8446422906616520626494
count=4558036012110548547798
count=2434549498994866786034
count=1287036656999057467424
count=673422983571685912648
count=348737888851294898280
count=178735377499734476360
count=90658265801360274016
count=45506194887963205806
count=22603387487011330494
count=11109477277752161064
count=5402634939088716388
count=2599348281853560988
count=1237186710532642568
count=582504495903896934
count=271258374586669636
count=124915774672520357
count=56888561881025689
count=25615767980815224
count=11399249487823014
count=5014926877132547
count=2180915576957059
count=936384359299208
count=397188128932528
count=166612052646818
count=68893011316114
count=28088731372888
count=11348888534124
count=4513130425164
count=1759354998368
count=683049732010
count=261506110220
count=96634341361
count=35818805501
count=13299438184
count=4606342574
count=1599386433
count=586908453
count=189264458
count=58562524
count=21967781
count=6714397
count=1655690
count=664210
count=206498
count=32856
count=14727
count=5330
count=390
count=198
count=101
count=2
count=1
count=1
我就不算的这么细了,先算前15项,然后只统计大于,等于,小于三种情况的频率。很快找到分别对应A371358, A163493,A371564, 也发现了生成函数。
tmp=Table[{n,Map-Count,{p,MovingMap&,#,1]&/@Tuples[{0,1},n]}],Sign]]},{n,2,10}];
#&/@tmp[]
#&/@tmp[]
#[-1]&/@tmp[]
expr={1/(2 (1-2 x))-(1+x)/(2 Sqrt[(1-x) (1-2 x) (1+x+2 x^2)]),1/(2 (1-x))+(1+2 x)/(2 Sqrt[(1-2 x) (1-x) (1+x+2 x^2)]),1/2x(1/(1-3 x+2 x^2)-1/Sqrt[(1-x) (1-2 x) (1+x+2 x^2)])};
SeriesCoefficient/2^100
{145031987309855208595272106851/316912650057057350374175801344,8957051571231018094490652819/158456325028528675187087900672,153966559604740105589922388855/316912650057057350374175801344}
也就是{0.45764, 0.0565269, 0.485833}
好像很容易证啊,遍历所有由H和T组成的长度为n的序列,其中HH(或任何其它两位组合)出现的总次数F(n)=(n-1)*2^(n-2),所以两种选择胜率相同。 好地方 发表于 2024-5-7 19:15
好像很容易证啊,遍历所有由H和T组成的长度为n的序列,其中HH(或任何其它两位组合)出现的总次数F(n)=(n-1)* ...
啊不对,可能出现HH平均赢的分差更大,但赢的次数少的情况 mathe 发表于 2024-3-21 21:44
设n个硬币的所有排列中,HH比HT多s个的方案中最后一个为HEAD的计数为count[ s ],
最后一个为TAIL ...
mathe的算法,我用Mathematica实现了一遍,结果完全一致
With[{n=100},ans=Nest|>,h-><|s+1->#|>],{s,Keys[#]}],Table|>,h-><|s->#|>],{s,Keys[#]}]},1],KeySort@Merge[#,Total]&]&,<|h-><|0->1,1->1|>,t-><|-1->1,0->1|>|>,n-2];
GroupBy,Total]],Sign[#[]]&,Total[#[]]&]]
<|-1->615866238418960422359689555420,0->71656412569848144755925222552,1->580127949239420834381088427404|>
页:
[1]
2