diff --git a/module2/exo1/toy_notebook_fr.ipynb b/module2/exo1/toy_notebook_fr.ipynb
index b34edd35502b951ed300ca6c98c2464607851fc5..56e4aee378f9ab791cc841a4011f45613718de56 100644
--- a/module2/exo1/toy_notebook_fr.ipynb
+++ b/module2/exo1/toy_notebook_fr.ipynb
@@ -14,40 +14,66 @@
"
March 28, 2019
"
]
},
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## 1. A propos du calcul de $\\pi$\n",
+ "\n",
+ "### 1.1. En demandant à la lib maths \n",
+ "Mon ordinateur m'indique que $\\pi$ vaut *approximativement*\n"
+ ]
+ },
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "1\n"
+ "3.141592653589793\n"
]
}
],
"source": [
- "x=1\n",
- "print(x)"
+ "from math import *\n",
+ "print(pi)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### 1.2. En utilisant la méthode des aiguilles de Buffon \n",
+ "\n",
+ "Mais calculé avec la **méthode** des [aiguilles de Buffon](http://fr.wikipedia.org/wiki/Aiguille_de_Buffon), on obtiendrait comme **approximation** :\n"
]
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 9,
"metadata": {},
"outputs": [
{
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "[1] 1\n"
- ]
+ "data": {
+ "text/plain": [
+ "3.128911138923655"
+ ]
+ },
+ "execution_count": 9,
+ "metadata": {},
+ "output_type": "execute_result"
}
],
"source": [
- "x=1\n",
- "print(x)"
+ "import numpy as np \n",
+ "np.random.seed(seed=42) \n",
+ "N = 10000 \n",
+ "x = np.random.uniform(size=N, low=0, high=1) \n",
+ "theta = np.random.uniform(size=N, low=0, high=pi/2) \n",
+ "2/(sum((x+np.sin(theta))>1)/N)\n"
]
},
{