From 0f29dfd851bb3feceb33a86cc2a7e321f5469989 Mon Sep 17 00:00:00 2001 From: 7ac60ea4ec07035af5dc69a60a92414e <7ac60ea4ec07035af5dc69a60a92414e@app-learninglab.inria.fr> Date: Wed, 22 Mar 2023 15:58:47 +0000 Subject: [PATCH] Update toy_document_fr.Rmd --- module2/exo1/toy_document_fr.Rmd | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/module2/exo1/toy_document_fr.Rmd b/module2/exo1/toy_document_fr.Rmd index 4831cb9..1d11239 100644 --- a/module2/exo1/toy_document_fr.Rmd +++ b/module2/exo1/toy_document_fr.Rmd @@ -36,4 +36,9 @@ 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() -``` \ No newline at end of file +``` + +Il est alors aisé d’obtenir une approximation (pas terrible) de π en comptant combien de fois, en moyenne, X2+Y2 est inférieur à 1: +```{r} +4*mean(df$Accept) +``` -- 2.18.1