"1 ## Avec un argument \"fréquentiel\" de surface\n",
"2 Sinon, une méthode plus simple à comprendre et ne faisant pas intervenir d'appel à la fonction sinus se base sur le fait que si $X\\sim U(0,1)$ et $Y\\sim U(0,1)$ alors $P[X^2+Y^2\\leq\n",
"1] = \\pi/4$ (voir [méthode de Monte Carlo sur Wikipedia]\n",
"(https://fr.wikipedia.org/wiki/M%C3%A9thode_de_Monte-Carlo#D%C3%A9termination_de_la_valeur_de_%CF%80)). Le code suivant illustre ce fait :\n",
"## Avec un argument \"fréquentiel\" de surface\n",
"Sinon, une méthode plus simple à comprendre et ne faisant pas intervenir d'appel à la fonction sinus se base sur le fait que si $X\\sim U(0,1)$ et $Y\\sim U(0,1)$ alors $P[X^2+Y^2\\leq1] = \\pi/4$ (voir [méthode de Monte Carlo sur Wikipedia](https://fr.wikipedia.org/wiki/M%C3%A9thode_de_Monte-Carlo#D%C3%A9termination_de_la_valeur_de_%CF%80)). Le code suivant illustre ce fait :\n",
"\n",
"\n",
"In [3]:\n",
"\n",
"1%matplotlib inline\n",
"2 iport matplotlib.pyplot as plt\n",
"3\n",
"4 np.random.dees(seed=42)\n",
"5 N = 1000\n",
"6 x = np.random.uniform(size=N, low=0, high=1)\n",
"7 y = np.random.uniform(size=N, low=0, high=1)\n",
"8\n",
"9 accept = (x*x+y*y) <=1\n",
"10 reject = np.logical_not'accept)\n",
"11\n",
"12 fig, ax = plt.subplots(1)\n",
"13 ax.scatter(x[accept], y [accept], c='b', alpha=0.2, edgecolor=None)\n",
"14 ax.scatter(x[reject], y [reject], c='r', alpha=0.2, edgecolor=None)\n",
"15 ax.set_aspect('equal')\n",
"%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",
"\n",
"accept = (x*x+y*y) <=1\n",
"reject = np.logical_not(accept)\n",
"\n",
"fig, ax = plt.subplots(1)\n",
"ax.scatter(x[accept], y [accept], c='b', alpha=0.2, edgecolor=None)\n",
"ax.scatter(x[reject], y [reject], c='r', alpha=0.2, edgecolor=None)\n",