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
e2900e5da2478df97d853a0667babc29
mooc-rr
Commits
2a5f2bbf
Commit
2a5f2bbf
authored
Jun 18, 2025
by
e2900e5da2478df97d853a0667babc29
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no commit message
parent
dea3cace
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
11 deletions
+46
-11
toy_notebook_fr.ipynb
module2/exo1/toy_notebook_fr.ipynb
+46
-11
No files found.
module2/exo1/toy_notebook_fr.ipynb
View file @
2a5f2bbf
{
{
"cells": [
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 1 À propos du calcul de π"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 1.1 En demandant à la lib maths\n",
"Mon ordinateur m’indique que π vaut approximativement"
]
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
5
,
"execution_count":
null
,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"3.141592653589793\n"
]
}
],
"source": [
"source": [
"from math import *\n",
"from math import *\n",
"print(pi)"
"print(pi)"
]
]
},
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 1.2 En utilisant la méthode des aiguilles de Buffon\n",
"Mais calculé avec la méthode des aiguilles de Buffon, on obtiendrait comme approximation :"
]
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 6,
"execution_count": 6,
...
@@ -43,10 +58,22 @@
...
@@ -43,10 +58,22 @@
"2/(sum((x+np.sin(theta))>1)/N)"
"2/(sum((x+np.sin(theta))>1)/N)"
]
]
},
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 1.3 Avec un argument \"fréquentiel\" de surface\n",
"Sinon, une méthode plus simple à comprendre et ne faisant pas intervenir d’appel à la fonction\n",
"sinus se base sur le fait que si X ∼ U(0, 1) et Y ∼ U(0, 1) alors P[X2 + Y2 ≤ 1] = π/4 (voir\n",
"méthode de Monte Carlo sur Wikipedia). Le code suivant illustre ce fait :"
]
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 7,
"execution_count": 7,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [
"outputs": [
{
{
"data": {
"data": {
...
@@ -77,6 +104,14 @@
...
@@ -77,6 +104,14 @@
"ax.set_aspect('equal')"
"ax.set_aspect('equal')"
]
]
},
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Il est alors aisé d’obtenir une approximation (pas terrible) de π en comptant combien de fois,\n",
"en moyenne, X2 + Y2 est inférieur à 1 :"
]
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 8,
"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