From 99c98cb5485fb952dd67bc371fb80edab07285af Mon Sep 17 00:00:00 2001 From: David Elser Date: Thu, 4 Mar 2021 10:21:04 +0100 Subject: [PATCH] final --- module2/exo1/toy_document_en.Rmd | 10 +++++----- module2/exo1/toy_document_en.html | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/module2/exo1/toy_document_en.Rmd b/module2/exo1/toy_document_en.Rmd index 81d98b2..6a55105 100644 --- a/module2/exo1/toy_document_en.Rmd +++ b/module2/exo1/toy_document_en.Rmd @@ -1,7 +1,7 @@ --- title: "On the computation of pi" -author: "*Arnaud Legrand*" -date: "*25 juin 2018*" +author: "Arnaud Legrand" +date: "25 juin 2018" output: html_document --- @@ -9,7 +9,7 @@ output: html_document knitr::opts_chunk$set(echo = TRUE) ``` -# Asking the maths libary +## Asking the maths library My computer tells me that $\pi$ is *approximatively* ```{r} @@ -17,7 +17,7 @@ pi ``` ## Buffon's needle -Applying the methond of [Buffon's needle](https://en.wikipedia.org/wiki/Buffon%27s_needle_problem), we get the __approximation__) +Applying the method of [Buffon's needle](https://en.wikipedia.org/wiki/Buffon%27s_needle_problem), we get the __approximation__) ```{r} set.seed(42) @@ -27,7 +27,7 @@ theta = pi/2*runif(N) 2/(mean(x+sin(theta)>1)) ``` -## Using a surface fraction arugment +## Using a surface fraction argument A method that is easier to understand and does not make use of the $\sin$ function is based on the fact that if $X\sim U(0,1)$ and $Y\sim U(0,1)$, then $P[X^2+Y^2\leq 1] = \pi/4$ (see ["Monte Carlo method" on Wikipedia](https://en.wikipedia.org/wiki/Monte_Carlo_method)). The following code uses this approach: ```{r} diff --git a/module2/exo1/toy_document_en.html b/module2/exo1/toy_document_en.html index e77f235..80f4d8c 100644 --- a/module2/exo1/toy_document_en.html +++ b/module2/exo1/toy_document_en.html @@ -375,20 +375,21 @@ $(document).ready(function () {

On the computation of pi

-

Arnaud Legrand

-

25 juin 2018

+

Arnaud Legrand

+

25 juin 2018

-
-

Asking the maths libary

+
+

Asking the maths library

My computer tells me that \(\pi\) is approximatively

pi
## [1] 3.141593
+

Buffon’s needle

-

Applying the methond of Buffon’s needle, we get the approximation)

+

Applying the method of Buffon’s needle, we get the approximation)

set.seed(42)
 N = 100000
 x = runif(N)
@@ -396,8 +397,8 @@ theta = pi/2*runif(N)
 2/(mean(x+sin(theta)>1))
## [1] 3.14327
-
-

Using a surface fraction arugment

+
+

Using a surface fraction argument

A method that is easier to understand and does not make use of the \(\sin\) function is based on the fact that if \(X\sim U(0,1)\) and \(Y\sim U(0,1)\), then \(P[X^2+Y^2\leq 1] = \pi/4\) (see “Monte Carlo method” on Wikipedia). The following code uses this approach:

set.seed(42)
 N = 1000
@@ -415,7 +416,6 @@ library(ggplot2)
4*mean(df$Accept)
## [1] 3.156
-
-- 2.18.1