diff --git a/module1/exo1/toy_document_fr.Rmd b/module1/exo1/toy_document_fr.Rmd new file mode 100644 index 0000000000000000000000000000000000000000..f62818d8709d185506800d4ab631eef11240f8b4 --- /dev/null +++ b/module1/exo1/toy_document_fr.Rmd @@ -0,0 +1,51 @@ + À propos du calcul de pi code{white-space: pre;} pre:not(\[class\]) { background-color: white; } if (window.hljs) { hljs.configure({languages: \[\]}); hljs.initHighlightingOnLoad(); if (document.readyState && document.readyState === "complete") { window.setTimeout(function() { hljs.initHighlighting(); }, 0); } } h1 { font-size: 34px; } h1.title { font-size: 38px; } h2 { font-size: 30px; } h3 { font-size: 24px; } h4 { font-size: 18px; } h5 { font-size: 16px; } h6 { font-size: 12px; } .table th:not(\[align\]) { text-align: left; } .main-container { max-width: 940px; margin-left: auto; margin-right: auto; } code { color: inherit; background-color: rgba(0, 0, 0, 0.04); } img { max-width:100%; height: auto; } .tabbed-pane { padding-top: 12px; } button.code-folding-btn:focus { outline: none; } + +$(document).ready(function () { window.buildTabsets("TOC"); }); + +À propos du calcul de pi +======================== + +#### _Arnaud Legrand_ + +#### _25 juin 2018_ + +En demandant à la lib maths +--------------------------- + +Mon ordinateur m’indique que \\(\\pi\\) vaut _approximativement_ + + pi + + +En utilisant la méthode des aiguilles de Buffon +----------------------------------------------- + +Mais calculé avec la **méthode** des [aiguilles de Buffon](https://fr.wikipedia.org/wiki/Aiguille_de_Buffon), on obtiendrait comme **approximation** : + + set.seed(42) + N = 100000 + x = runif(N) + theta = pi/2*runif(N) + 2/(mean(x+sin(theta)>1)) + + +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^2+Y^2\\leq 1\] = \\pi/4\\) (voir [méthode de Monte Carlo sur 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: + + set.seed(42) + N = 1000 + df = data.frame(X = runif(N), Y = runif(N)) + df$Accept = (df$X**2 + df$Y**2 <=1) + library(ggplot2) + ggplot(df, aes(x=X,y=Y,color=Accept)) + geom_point(alpha=.2) + coord_fixed() + theme_bw() + + + +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: + + 4*mean(df$Accept) + + +