Exo 1 Updates 2

parent 5e64298d
...@@ -4,14 +4,24 @@ ...@@ -4,14 +4,24 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"# toy_note_book_fr\n", "# toy_note_book_fr"
"\n", ]
"March 28, 2019\n", },
"\n", {
"cell_type": "markdown",
"metadata": {},
"source": [
"March 28, 2019"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. A propos du calcul de pi\n", "## 1. A propos du calcul de pi\n",
"### 1.1 En demandant à la lib maths\n", "### 1.1 En demandant à la lib maths\n",
"\n", "\n",
"Mon ordi m'indique que pi vaut approximativement" "Mon ordi m'indique que $\\pi$ vaut *approximativement*"
] ]
}, },
{ {
...@@ -38,23 +48,20 @@ ...@@ -38,23 +48,20 @@
"source": [ "source": [
"### 1.2 En utilisant la méthode des aiguilles de Buffon\n", "### 1.2 En utilisant la méthode des aiguilles de Buffon\n",
"\n", "\n",
"Mais calculé avec la méthode des aiguilles de Buffon, on obtiendrait comme approximation:" "Mais calculé avec la **méthode** des [aiguilles de Buffon](https://fr.wikipedia.org/wiki/Aiguille_de_Buffon), on obtiendrait comme **approximation**:"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 2,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"ename": "NameError", "ename": "SyntaxError",
"evalue": "name 'pi' is not defined", "evalue": "invalid syntax (<ipython-input-2-f24264f0d041>, line 5)",
"output_type": "error", "output_type": "error",
"traceback": [ "traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;36m File \u001b[0;32m\"<ipython-input-2-f24264f0d041>\"\u001b[0;36m, line \u001b[0;32m5\u001b[0m\n\u001b[0;31m theta = np.random.uniform(size=N, low=0, high=%pi/2)\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n"
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-4-e6a8ec42a72f>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mN\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m10000\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mx\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrandom\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0muniform\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msize\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mN\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlow\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mhigh\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0mtheta\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrandom\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0muniform\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msize\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mN\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlow\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mhigh\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mpi\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msum\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtheta\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m>\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0mN\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'pi' is not defined"
] ]
} }
], ],
...@@ -73,12 +80,12 @@ ...@@ -73,12 +80,12 @@
"source": [ "source": [
"### 1.3 Avec un argument \"fréquentiel\" de surface\n", "### 1.3 Avec un argument \"fréquentiel\" de surface\n",
"\n", "\n",
"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^2$ + $Y^2$ $\\le$ 1] = pi/4 (voir méthode de Monte-Carlo sur Wikipedia). Le code suivant illustre ce fait :" "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 \\sim U(0,1)$ et $Y \\sim U(0,1)$ alors $P[X^2 + Y^2 \\le 1] = \\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 :"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 9,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -115,7 +122,7 @@ ...@@ -115,7 +122,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"Il est alors aisé d'obtenir une approximation (pas terrible) de pi en comptant combien de fois, en moyenne, $X^2$ + $Y^2$ est inférieur à 1:" "Il est alors aisé d'obtenir une approximation (pas terrible) de $\\pi$ en comptant combien de fois, en moyenne, $X^2$ + $Y^2$ est inférieur à 1:"
] ]
}, },
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment