Avance jusqu'à 1.3 non inclut

parent 0cedbe83
......@@ -4,23 +4,21 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# toy_notebook_fr"
"# A propos du calcul de $\\pi$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## March 28,2019\n"
"## En demandant à la lib maths"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1.A propos du calcul de :pi:\n",
"1.1 En demandant à la lib maths\n",
"Mon ordinateur m'indique que :pi: vaut *approximativement*"
"Mon ordinateur m'indique que $\\pi$ vaut *approximativement*"
]
},
{
......@@ -41,12 +39,46 @@
"print(pi)"
]
},
{
"cell_type": "markdown",
"metadata": {
"hideOutput": true
},
"source": [
"## En utilisant la méthode des aiguilles de Buffon"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Mais calculé avec la **méthode** des aiguilles de Buffon, on obtiendrait comme **approximation** :"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"data": {
"text/plain": [
"3.128911138923655"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"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)"
]
}
],
"metadata": {
......
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