Last active
January 9, 2021 23:48
-
-
Save camilajenny/1cc83dc9415fdb3665b50ed0a32cbe24 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": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"import matplotlib.pyplot as plt" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"drzwi - 0, 1, 2 \n", | |
"bez straty na ogolnosci mozemy zalozyc, ze wybieramy drzwi 0, a prowadzacy odslania w pierwszej rundzie\n", | |
"drzwi 1, jesli sa puste i 2 w przeciwnym przypadku" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 25, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"stay strategy: 333329\n", | |
"change strategy: 666671\n" | |
] | |
} | |
], | |
"source": [ | |
"stayResult = 0 # pozostajemy przy tych samych drzwiach\n", | |
"changeResult = 0 # pozostajemy przy tych samych drzwiach\n", | |
"N = 1000000 # ilosc prob \n", | |
"stayDoor = 0\n", | |
"for i in range(N):\n", | |
" prizeDoor = np.random.randint(3)\n", | |
" if prizeDoor == 1: # prowadzacy odslonil 2\n", | |
" changeDoor = 1\n", | |
" else: # prowadzacy odslonil 1\n", | |
" changeDoor = 2\n", | |
" if prizeDoor == stayDoor:\n", | |
" stayResult += 1\n", | |
" if prizeDoor == changeDoor:\n", | |
" changeResult += 1\n", | |
"\n", | |
"print('stay strategy: %d\\nchange strategy: %d' % (stayResult, changeResult))" | |
] | |
} | |
], | |
"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.1" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment