Created
September 11, 2021 18:17
-
-
Save foxqstm/269d52e760cfc5fc1cb9bb2fb884aab8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 389, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[('D', 0.0), ('De', 0.0), ('C', 0.001), ('G', 0.021), ('Y', 0.086), ('H', 0.892)]\n" | |
] | |
} | |
], | |
"source": [ | |
"import random\n", | |
"\n", | |
"Team=['H','Y','G','D','C','De']\n", | |
"\n", | |
"p=dict()\n", | |
"p['H']=0.581\n", | |
"p['Y']=0.560\n", | |
"p['G']=0.547\n", | |
"p['D']=0.448\n", | |
"p['C']=0.433\n", | |
"p['De']=0.432\n", | |
"\n", | |
"w=dict()\n", | |
"w['H']=0.0\n", | |
"w['Y']=3.0\n", | |
"w['G']=4.0\n", | |
"w['D']=13.5\n", | |
"w['C']=15.0\n", | |
"w['De']=15.0\n", | |
"\n", | |
"\n", | |
"z=dict()\n", | |
"z['H']=34\n", | |
"z['Y']=40\n", | |
"z['G']=33\n", | |
"z['D']=33\n", | |
"z['C']=36\n", | |
"z['De']=34\n", | |
"\n", | |
"wp=dict()\n", | |
"wp['H']=0.0\n", | |
"wp['Y']=-3.0\n", | |
"wp['G']=-4.0\n", | |
"wp['D']=-13.5\n", | |
"wp['C']=-15.0\n", | |
"wp['De']=-15.0\n", | |
"\n", | |
"sample=1000\n", | |
"c=dict()\n", | |
"c['H']=0\n", | |
"c['Y']=0\n", | |
"c['G']=0\n", | |
"c['D']=0\n", | |
"c['C']=0\n", | |
"c['De']=0\n", | |
"\n", | |
"for s in range(1,sample+1):\n", | |
" for T in Team:\n", | |
" for i in range(1,z[T]+1):\n", | |
" Tvs=random.choice(Team)\n", | |
" if random.random()<=p[T]:\n", | |
" w[T]+=0.5\n", | |
" w[Tvs]-=0.5\n", | |
" else:\n", | |
" w[T]-=0.5\n", | |
" w[Tvs]+=0.5\n", | |
" \n", | |
" wT=sorted(w.items(),key=lambda x:x[1])\n", | |
" c[wT[-1][0]]+=1\n", | |
"\n", | |
"sumwin=0\n", | |
"for T in Team:\n", | |
" sumwin+=c[T]\n", | |
"for T in Team:\n", | |
" c[T]/=sumwin\n", | |
" \n", | |
"wT=sorted(c.items(),key=lambda x:x[1])\n", | |
"print(wT)\n", | |
" " | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment