From 03c096610b6e2de0be2c67b4d2956a8cbc79ea42 Mon Sep 17 00:00:00 2001 From: c4f342ae5e5291c5f1e720fbecb42719 Date: Mon, 6 Feb 2023 14:48:17 +0100 Subject: [PATCH] very last one, I hope... Pi --- module2/exo1/toy_document_fr.Rmd | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/module2/exo1/toy_document_fr.Rmd b/module2/exo1/toy_document_fr.Rmd index 02118e1..5386973 100644 --- a/module2/exo1/toy_document_fr.Rmd +++ b/module2/exo1/toy_document_fr.Rmd @@ -37,8 +37,12 @@ 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 : + ```{r} 4*mean(df$Accept) -``` \ No newline at end of file +``` + -- 2.18.1