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
Émile Jetzer
mooc-rr
Commits
8ee13f65
Commit
8ee13f65
authored
May 14, 2020
by
Émile Jetzer
🎱
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Corrections après avoir vu le corrigé
parent
33c48a1c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
toy_document_orgmode_python_fr.org
module2/exo1/toy_document_orgmode_python_fr.org
+11
-5
No files found.
module2/exo1/toy_document_orgmode_python_fr.org
View file @
8ee13f65
...
...
@@ -15,7 +15,7 @@
Mon ordinateur m'indique que \(\pi\) vaut /approximativement/:
#+begin_src python :
export both :session "Python"
#+begin_src python :
results value :session "Python" :exports both
import math
math.pi
#+end_src
...
...
@@ -29,7 +29,7 @@ Mais calculé avec la *méthode* des [aiguilles de
Buffon](https://fr.wikipedia.org/wiki/Aiguille_de_Buffon), on
obtiendrait comme *approximation*:
#+begin_src python :
session "Python"
#+begin_src python :
results value :session "Python" :exports both
import numpy as np
np.random.seed(seed=42)
N=10000
...
...
@@ -50,7 +50,7 @@ intervenir d'appel à la fonction sinus se base sur le fait que si
Wikipedia](https://fr.wikipedia.org/wiki/M%C3%A9thode_de_Monte-Carlo#D%C3%A9termination_de_la_valeur_de_%CF%80). Le
code suivant illustre ce fait:
#+begin_src python
:session "Python" :export
both
#+begin_src python
:results output file :var matplot_lib_filename="figure_pi_mc2.png" :session "Python" :exports
both
import matplotlib.pyplot as plt
np.random.seed(seed=42)
...
...
@@ -71,15 +71,21 @@ print(matplot_lib_filename)
#+end_src
#+RESULTS:
: <matplotlib.collections.PathCollection object at 0x11abb2940>
[[file:]]
Il est alors aisé d'obtenir une approximation (pas terrible) de \(\pi\)
en comptant combien de fois, en moyenne, \(X^2+Y^2\) est inférieur à 1:
#+begin_src python :
session "Python"
#+begin_src python :
results output :session "Python" :exports both
4*np.mean(accept)
#+end_src
#+RESULTS:
: 3.112
:
:
]]
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