no commit message

parent 2af918f3
{
"cells": [
{
"cell_type": "markdown",
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"## Méthode des aiguilles de Buffon\n",
"import random\n",
"import math\n",
"\n",
"Pour en savoir plus : \n",
"[Expérience des aiguilles de Buffon (Wikipedia)](https://fr.wikipedia.org/wiki/Aiguille_de_Buffon)"
"def buffon_needle(n_drops=100000):\n",
" hits = 0\n",
" for _ in range(n_drops):\n",
" y = random.random()\n",
" theta = random.uniform(0, math.pi / 2)\n",
" if y <= (math.sin(theta) / 2):\n",
" hits += 1\n",
" return (2 * n_drops) / hits\n",
"\n",
"pi_est = buffon_needle()\n",
"print(f\"Estimation de π par la méthode de Buffon : {pi_est}\")\n"
]
}
],
......
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