Commit a9236df9 authored by hakimouaras's avatar hakimouaras

Corrections

parent 6e9c9781
...@@ -18,26 +18,26 @@ ...@@ -18,26 +18,26 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## À propos du calcul de $\\pi$ " "# À propos du calcul de $\\pi$ "
] ]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"### En demandant à la lib maths" "## En demandant à la lib maths"
] ]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"Mon ordinateur m’indique que $\\pi$ vaut approximativement" "Mon ordinateur m’indique que $\\pi$ vaut *approximativement*"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 9,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
} }
], ],
"source": [ "source": [
"from math import * \n", "from math import *\n",
"print(pi)" "print(pi)"
] ]
}, },
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"### En utilisant la méthode des aiguilles de Buffon " "## En utilisant la méthode des aiguilles de Buffon "
] ]
}, },
{ {
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 10,
"metadata": { "metadata": {
"scrolled": true "scrolled": true
}, },
...@@ -80,17 +80,17 @@ ...@@ -80,17 +80,17 @@
"3.128911138923655" "3.128911138923655"
] ]
}, },
"execution_count": 6, "execution_count": 10,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
], ],
"source": [ "source": [
"import numpy as np \n", "import numpy as np\n",
"np.random.seed(seed=42) \n", "np.random.seed(seed=42)\n",
"N = 10000 \n", "N = 10000\n",
"x = np.random.uniform(size=N, low=0, high=1) \n", "x = np.random.uniform(size=N, low=0, high=1)\n",
"theta = np.random.uniform(size=N, low=0, high=pi/2) \n", "theta = np.random.uniform(size=N, low=0, high=pi/2)\n",
"2/(sum((x+np.sin(theta))>1)/N)" "2/(sum((x+np.sin(theta))>1)/N)"
] ]
}, },
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"### Avec un argument \"fréquentiel\" de surface " "## Avec un argument \"fréquentiel\" de surface "
] ]
}, },
{ {
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": 11,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -130,19 +130,19 @@ ...@@ -130,19 +130,19 @@
} }
], ],
"source": [ "source": [
"%matplotlib inline \n", "%matplotlib inline\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"\n", "\n",
"np.random.seed(seed=42) \n", "np.random.seed(seed=42)\n",
"N = 1000 \n", "N = 1000\n",
"x = np.random.uniform(size=N, low=0, high=1) \n", "x = np.random.uniform(size=N, low=0, high=1)\n",
"y = np.random.uniform(size=N, low=0, high=1)\n", "y = np.random.uniform(size=N, low=0, high=1)\n",
"accept = (x*x+y*y) <= 1 \n", "accept = (x*x+y*y) <= 1\n",
"reject = np.logical_not(accept)\n", "reject = np.logical_not(accept)\n",
"\n", "\n",
"fig, ax = plt.subplots(1) \n", "fig, ax = plt.subplots(1) \n",
"ax.scatter(x[accept], y[accept], c='b', alpha=0.2, edgecolor=None) \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", "ax.scatter(x[reject], y[reject], c='r', alpha=0.2, edgecolor=None)\n",
"ax.set_aspect('equal')" "ax.set_aspect('equal')"
] ]
}, },
...@@ -156,7 +156,7 @@ ...@@ -156,7 +156,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": 12,
"metadata": { "metadata": {
"scrolled": true "scrolled": true
}, },
...@@ -167,7 +167,7 @@ ...@@ -167,7 +167,7 @@
"3.112" "3.112"
] ]
}, },
"execution_count": 8, "execution_count": 12,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
......
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