Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mooc-rr
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
036332d1e8a8fad18eace193f300e27a
mooc-rr
Commits
62610cf3
Commit
62610cf3
authored
Jun 20, 2025
by
036332d1e8a8fad18eace193f300e27a
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pi estimate- Added Notes
parent
f03f7cbe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
12 deletions
+22
-12
toy_notebook_fr.ipynb
module2/exo1/toy_notebook_fr.ipynb
+22
-12
No files found.
module2/exo1/toy_notebook_fr.ipynb
View file @
62610cf3
...
...
@@ -4,23 +4,17 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# À propos de pi"
"### Estimating π\n",
"\n",
"I tried to compute pi using Buffon’s Needle method with random numbers to estimate the value of π. \n",
"The result is close to 3.14, showing how randomness can be used in simulations."
]
},
{
"cell_type": "code",
"execution_count": 1,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": [
"from random import random \n",
"N=10000\n",
"val=sum(\n",
"1 for _ in range(N)\n",
" if random()**2 + random()**2 <= 1\n",
")\n",
"\n",
"pi_estimate = 4 * val / N"
"# About Pi"
]
},
{
...
...
@@ -34,6 +28,22 @@
"Donc : $\\pi \\approx 4 \\times \\frac{\\text{points dans le cercle}}{\\text{points totaux}}$\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from random import random \n",
"N=10000\n",
"val=sum(\n",
"1 for _ in range(N)\n",
" if random()**2 + random()**2 <= 1\n",
")\n",
"\n",
"pi_estimate = 4 * val / N"
]
},
{
"cell_type": "code",
"execution_count": 8,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment