"Sinon, une méthode plus simple à comprendre et ne faisant pas intervenir d'apel à la fonction sinus se base sur le fait que si X ~ U(0,1) et Y ~ U(0,1) alors P[X² + Y² < 1] = pi/4 (voir méthode de Monte-Carlo sur Wikipedia). Le code suivant illustre ce fait :"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"ename": "IndentationError",
"evalue": "unexpected indent (<ipython-input-1-c47c06b12806>, line 2)",
"output_type": "error",
"traceback": [
"\u001b[0;36m File \u001b[0;32m\"<ipython-input-1-c47c06b12806>\"\u001b[0;36m, line \u001b[0;32m2\u001b[0m\n\u001b[0;31m import matplotlib.pyplot as plt\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mIndentationError\u001b[0m\u001b[0;31m:\u001b[0m unexpected indent\n"
]
}
],
"source": [
"In [3]: %matplotlib inline\n",
" import matplotlib.pyplot as plt\n",
" \n",
" np.random.seed(seed=42)\n",
" N = 1000\n",
" x = np.random.uniform(size=N, low=0, high=1)\n",
" y = np.random.uniform(size=N, low=0, high=1)\n",