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
40b967d450cc73a5ec8d086a42cb7ff3
mooc-rr
Commits
347236a2
Commit
347236a2
authored
Nov 02, 2021
by
40b967d450cc73a5ec8d086a42cb7ff3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
toy_document_orgmode_R_fr.org: Update
parent
bdb67615
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
toy_document_orgmode_R_fr.org
module2/exo1/toy_document_orgmode_R_fr.org
+9
-9
No files found.
module2/exo1/toy_document_orgmode_R_fr.org
View file @
347236a2
...
...
@@ -21,7 +21,8 @@ pi
* En utilisant la méthode des aiguilles de Buffon
Mais calculé avec la *méthode* des [[https://fr.wikipedia.org/wiki/Aiguille_de_Buffon][aiguilles de Buffon]], on obtiendrait comme *approximation* :
Mais calculé avec la *méthode* des [[https://fr.wikipedia.org/wiki/Aiguille_de_Buffon][aiguilles de Buffon]], on obtiendrait
comme *approximation* :
#+begin_src R :results output :session *R* :exports both
set.seed(42)
...
...
@@ -32,17 +33,16 @@ theta = pi/2*runif(N)
#+end_src
#+RESULTS:
:
: [1] 3.14327
* Avec un argument "fréquentiel" de surface
Sinon, une méthode plus simple à comprendre et ne faisant pas
intervenir d'appel à la fonction sinus se base sur le fait que si $X \sim
U(0,1)$ et $Y \sim U(0,1)$ alors $P[X² + Y² \le 1] = \pi/4$ (voir
[[https://fr.wikipedia.org/wiki/M%C3%A9thode_de_Monte-Carlo#D%C3%A9termination_de_la_valeur_de_%CF%80][méthode de Monte Carlo sur Wikipédia]]). L
e
code suivant illustre ce fait :
intervenir d'appel à la fonction sinus se base sur le fait que si $X \sim
U(0,1)$ et $Y \sim U(0,1)$ alors $P[X² + Y² \le 1] = \pi/4$ (voir [[https://fr.wikipedia.org/wiki/M%C3%A9thode_de_Monte-Carlo#D%C3%A9termination_de_la_valeur_de_%CF%80][méthode d
e
Monte Carlo sur Wikipédia]]). Le
code suivant illustre ce fait :
#+begin_src R :results output graphics :file
(org-babel-temp-file "figure" ".png")
:exports both :width 600 :height 400 :session *R*
#+begin_src R :results output graphics :file
figure_exo1.png
:exports both :width 600 :height 400 :session *R*
set.seed(42)
N = 1000
df = data.frame(X = runif(N), Y = runif(N))
...
...
@@ -52,7 +52,7 @@ ggplot(df, aes(x=X,y=Y,color=Accept)) + geom_point(alpha=.2) + coord_fixed() + t
#+end_src
#+RESULTS:
[[file:
/tmp/babel-mEAAPj/figureTP5NNK
.png]]
[[file:
figure_exo1
.png]]
Il est alors aisé d'obtenir une approximation (pas terrible) de \pi en
comptant combien de fois, en moyenne, $X² + Y²$ est inférieur à 1 :
...
...
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