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
197adccdacbb60bb13053a3357332d5b
mooc-rr
Commits
3acaf1f5
Commit
3acaf1f5
authored
Sep 05, 2024
by
Gwenael Dumont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RAS
parent
eaaf50e3
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
623 additions
and
8 deletions
+623
-8
.gitignore
module2/exo1/.gitignore
+1
-0
toy_document_fr.Rmd
module2/exo1/toy_document_fr.Rmd
+1
-6
toy_document_fr.html
module2/exo1/toy_document_fr.html
+1
-2
toy_document_fr.log
module2/exo1/toy_document_fr.log
+408
-0
toy_document_fr.tex
module2/exo1/toy_document_fr.tex
+199
-0
mooc-rr.Rproj
mooc-rr.Rproj
+13
-0
No files found.
module2/exo1/.gitignore
0 → 100644
View file @
3acaf1f5
toy_document_fr.html
module2/exo1/toy_document_fr.Rmd
View file @
3acaf1f5
---
output:
html_document: default
pdf_document: default
---
# À propos du calcul de pi
_Arnaud Legrand_
_25 juin 2018_
## En demandant à la lib maths
Mon ordinateur m’indique que $\pi$ vaut _approximativement_
...
...
module2/exo1/toy_document_fr.html
View file @
3acaf1f5
...
...
@@ -166,8 +166,7 @@ pre code {
<div
id=
"à-propos-du-calcul-de-pi"
class=
"section level1"
>
<h1>
À propos du calcul de pi
</h1>
<p><em>
Arnaud Legrand
</em></p>
<p><em>
25 juin 2018
</em></p>
<p><em>
Arnaud Legrand
</em>
<em>
25 juin 2018
</em></p>
<div
id=
"en-demandant-à-la-lib-maths"
class=
"section level2"
>
<h2>
En demandant à la lib maths
</h2>
<p>
Mon ordinateur m’indique que
<span
class=
"math inline"
>
\(\pi\)
</span>
vaut
<em>
approximativement
</em></p>
...
...
module2/exo1/toy_document_fr.log
0 → 100644
View file @
3acaf1f5
This diff is collapsed.
Click to expand it.
module2/exo1/toy_document_fr.tex
0 → 100644
View file @
3acaf1f5
% Options for packages loaded elsewhere
\PassOptionsToPackage
{
unicode
}{
hyperref
}
\PassOptionsToPackage
{
hyphens
}{
url
}
%
\documentclass
[
]
{
article
}
\usepackage
{
amsmath,amssymb
}
\usepackage
{
lmodern
}
\usepackage
{
iftex
}
\ifPDFTeX
\usepackage
[T1]
{
fontenc
}
\usepackage
[utf8]
{
inputenc
}
\usepackage
{
textcomp
}
% provide euro and other symbols
\else
% if luatex or xetex
\usepackage
{
unicode-math
}
\defaultfontfeatures
{
Scale=MatchLowercase
}
\defaultfontfeatures
[\rmfamily]
{
Ligatures=TeX,Scale=1
}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists
{
upquote.sty
}{
\usepackage
{
upquote
}}{}
\IfFileExists
{
microtype.sty
}{
% use microtype if available
\usepackage
[]
{
microtype
}
\UseMicrotypeSet
[protrusion]
{
basicmath
}
% disable protrusion for tt fonts
}{}
\makeatletter
\@
ifundefined
{
KOMAClassName
}{
% if non-KOMA class
\IfFileExists
{
parskip.sty
}{
%
\usepackage
{
parskip
}
}{
% else
\setlength
{
\parindent
}{
0pt
}
\setlength
{
\parskip
}{
6pt plus 2pt minus 1pt
}}
}{
% if KOMA class
\KOMAoptions
{
parskip=half
}}
\makeatother
\usepackage
{
xcolor
}
\IfFileExists
{
xurl.sty
}{
\usepackage
{
xurl
}}{}
% add URL line breaks if available
\IfFileExists
{
bookmark.sty
}{
\usepackage
{
bookmark
}}{
\usepackage
{
hyperref
}}
\hypersetup
{
hidelinks,
pdfcreator=
{
LaTeX via pandoc
}}
\urlstyle
{
same
}
% disable monospaced font for URLs
\usepackage
[margin=1in]
{
geometry
}
\usepackage
{
color
}
\usepackage
{
fancyvrb
}
\newcommand
{
\VerbBar
}{
|
}
\newcommand
{
\VERB
}{
\Verb
[commandchars=\\\{\}]
}
\DefineVerbatimEnvironment
{
Highlighting
}{
Verbatim
}{
commandchars=
\\\{\}
}
% Add ',fontsize=\small' for more characters per line
\usepackage
{
framed
}
\definecolor
{
shadecolor
}{
RGB
}{
248,248,248
}
\newenvironment
{
Shaded
}{
\begin{snugshade}
}{
\end{snugshade}
}
\newcommand
{
\AlertTok
}
[1]
{
\textcolor
[rgb]
{
0.94,0.16,0.16
}{
#1
}}
\newcommand
{
\AnnotationTok
}
[1]
{
\textcolor
[rgb]
{
0.56,0.35,0.01
}{
\textbf
{
\textit
{
#1
}}}}
\newcommand
{
\AttributeTok
}
[1]
{
\textcolor
[rgb]
{
0.77,0.63,0.00
}{
#1
}}
\newcommand
{
\BaseNTok
}
[1]
{
\textcolor
[rgb]
{
0.00,0.00,0.81
}{
#1
}}
\newcommand
{
\BuiltInTok
}
[1]
{
#1
}
\newcommand
{
\CharTok
}
[1]
{
\textcolor
[rgb]
{
0.31,0.60,0.02
}{
#1
}}
\newcommand
{
\CommentTok
}
[1]
{
\textcolor
[rgb]
{
0.56,0.35,0.01
}{
\textit
{
#1
}}}
\newcommand
{
\CommentVarTok
}
[1]
{
\textcolor
[rgb]
{
0.56,0.35,0.01
}{
\textbf
{
\textit
{
#1
}}}}
\newcommand
{
\ConstantTok
}
[1]
{
\textcolor
[rgb]
{
0.00,0.00,0.00
}{
#1
}}
\newcommand
{
\ControlFlowTok
}
[1]
{
\textcolor
[rgb]
{
0.13,0.29,0.53
}{
\textbf
{
#1
}}}
\newcommand
{
\DataTypeTok
}
[1]
{
\textcolor
[rgb]
{
0.13,0.29,0.53
}{
#1
}}
\newcommand
{
\DecValTok
}
[1]
{
\textcolor
[rgb]
{
0.00,0.00,0.81
}{
#1
}}
\newcommand
{
\DocumentationTok
}
[1]
{
\textcolor
[rgb]
{
0.56,0.35,0.01
}{
\textbf
{
\textit
{
#1
}}}}
\newcommand
{
\ErrorTok
}
[1]
{
\textcolor
[rgb]
{
0.64,0.00,0.00
}{
\textbf
{
#1
}}}
\newcommand
{
\ExtensionTok
}
[1]
{
#1
}
\newcommand
{
\FloatTok
}
[1]
{
\textcolor
[rgb]
{
0.00,0.00,0.81
}{
#1
}}
\newcommand
{
\FunctionTok
}
[1]
{
\textcolor
[rgb]
{
0.00,0.00,0.00
}{
#1
}}
\newcommand
{
\ImportTok
}
[1]
{
#1
}
\newcommand
{
\InformationTok
}
[1]
{
\textcolor
[rgb]
{
0.56,0.35,0.01
}{
\textbf
{
\textit
{
#1
}}}}
\newcommand
{
\KeywordTok
}
[1]
{
\textcolor
[rgb]
{
0.13,0.29,0.53
}{
\textbf
{
#1
}}}
\newcommand
{
\NormalTok
}
[1]
{
#1
}
\newcommand
{
\OperatorTok
}
[1]
{
\textcolor
[rgb]
{
0.81,0.36,0.00
}{
\textbf
{
#1
}}}
\newcommand
{
\OtherTok
}
[1]
{
\textcolor
[rgb]
{
0.56,0.35,0.01
}{
#1
}}
\newcommand
{
\PreprocessorTok
}
[1]
{
\textcolor
[rgb]
{
0.56,0.35,0.01
}{
\textit
{
#1
}}}
\newcommand
{
\RegionMarkerTok
}
[1]
{
#1
}
\newcommand
{
\SpecialCharTok
}
[1]
{
\textcolor
[rgb]
{
0.00,0.00,0.00
}{
#1
}}
\newcommand
{
\SpecialStringTok
}
[1]
{
\textcolor
[rgb]
{
0.31,0.60,0.02
}{
#1
}}
\newcommand
{
\StringTok
}
[1]
{
\textcolor
[rgb]
{
0.31,0.60,0.02
}{
#1
}}
\newcommand
{
\VariableTok
}
[1]
{
\textcolor
[rgb]
{
0.00,0.00,0.00
}{
#1
}}
\newcommand
{
\VerbatimStringTok
}
[1]
{
\textcolor
[rgb]
{
0.31,0.60,0.02
}{
#1
}}
\newcommand
{
\WarningTok
}
[1]
{
\textcolor
[rgb]
{
0.56,0.35,0.01
}{
\textbf
{
\textit
{
#1
}}}}
\usepackage
{
graphicx
}
\makeatletter
\def\maxwidth
{
\ifdim\Gin
@nat@width>
\linewidth\linewidth\else\Gin
@nat@width
\fi
}
\def\maxheight
{
\ifdim\Gin
@nat@height>
\textheight\textheight\else\Gin
@nat@height
\fi
}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys
{
Gin
}{
width=
\maxwidth
,height=
\maxheight
,keepaspectratio
}
% Set default figure placement to htbp
\makeatletter
\def\fps
@figure
{
htbp
}
\makeatother
\setlength
{
\emergencystretch
}{
3em
}
% prevent overfull lines
\providecommand
{
\tightlist
}{
%
\setlength
{
\itemsep
}{
0pt
}
\setlength
{
\parskip
}{
0pt
}}
\setcounter
{
secnumdepth
}{
-
\maxdimen
}
% remove section numbering
\ifLuaTeX
\usepackage
{
selnolig
}
% disable illegal ligatures
\fi
\author
{}
\date
{
\vspace
{
-2.5em
}}
\begin{document}
\hypertarget
{
uxe0-propos-du-calcul-de-pi
}{
%
\section
{
À propos du calcul de pi
}
\label
{
uxe0-propos-du-calcul-de-pi
}}
\emph
{
Arnaud Legrand
}
\emph
{
25 juin 2018
}
\hypertarget
{
en-demandant-uxe0-la-lib-maths
}{
%
\subsection
{
En demandant à la lib
maths
}
\label
{
en-demandant-uxe0-la-lib-maths
}}
Mon ordinateur m'indique que π vaut
\emph
{
approximativement
}
\begin{Shaded}
\begin{Highlighting}
[]
\NormalTok
{
pi
}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## [1] 3.141593
\end{verbatim}
\hypertarget
{
en-utilisant-la-muxe9thode-des-aiguilles-de-buffon
}{
%
\subsection
{
En utilisant la méthode des aiguilles de
Buffon
}
\label
{
en-utilisant-la-muxe9thode-des-aiguilles-de-buffon
}}
Mais calculé avec la
\textbf
{
méthode
}
des
\href
{
https://fr.wikipedia.org/wiki/Aiguille
_
de
_
Buffon
}{
aiguilles de
Buffon
}
, on obtiendrait comme
\textbf
{
approximation
}
:
\begin{Shaded}
\begin{Highlighting}
[]
\FunctionTok
{
set.seed
}
\NormalTok
{
(
}
\DecValTok
{
42
}
\NormalTok
{
)
}
\NormalTok
{
N
}
\OtherTok
{
=
}
\DecValTok
{
100000
}
\NormalTok
{
x
}
\OtherTok
{
=
}
\FunctionTok
{
runif
}
\NormalTok
{
(N)
}
\NormalTok
{
theta
}
\OtherTok
{
=
}
\NormalTok
{
pi
}
\SpecialCharTok
{
/
}
\DecValTok
{
2
}
\SpecialCharTok
{
*
}
\FunctionTok
{
runif
}
\NormalTok
{
(N)
}
\DecValTok
{
2
}
\SpecialCharTok
{
/
}
\NormalTok
{
(
}
\FunctionTok
{
mean
}
\NormalTok
{
(x
}
\SpecialCharTok
{
+
}
\FunctionTok
{
sin
}
\NormalTok
{
(theta)
}
\SpecialCharTok
{
\textgreater
{}}
\DecValTok
{
1
}
\NormalTok
{
))
}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## [1] 3.14327
\end{verbatim}
\hypertarget
{
avec-un-argument-fruxe9quentiel-de-surface
}{
%
\subsection
{
Avec un argument ``fréquentiel'' de
surface
}
\label
{
avec-un-argument-fruxe9quentiel-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∼U(0,1) et
Y∼U(0,1) alors P
{
[
}
X2+Y2≤1
{
]
}
=π/4 (voir
\href
{
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 Wikipedia
}
). Le code suivant illustre ce fait:
\begin{Shaded}
\begin{Highlighting}
[]
\FunctionTok
{
set.seed
}
\NormalTok
{
(
}
\DecValTok
{
42
}
\NormalTok
{
)
}
\NormalTok
{
N
}
\OtherTok
{
=
}
\DecValTok
{
1000
}
\NormalTok
{
df
}
\OtherTok
{
=
}
\FunctionTok
{
data.frame
}
\NormalTok
{
(
}
\AttributeTok
{
X =
}
\FunctionTok
{
runif
}
\NormalTok
{
(N),
}
\AttributeTok
{
Y =
}
\FunctionTok
{
runif
}
\NormalTok
{
(N))
}
\NormalTok
{
df
}
\SpecialCharTok
{$}
\NormalTok
{
Accept
}
\OtherTok
{
=
}
\NormalTok
{
(
df
}
\SpecialCharTok
{$}
\NormalTok
{
X
}
\SpecialCharTok
{
**
}
\DecValTok
{
2
}
\SpecialCharTok
{
+
}
\NormalTok
{
df
}
\SpecialCharTok
{$}
\NormalTok
{
Y
}
\SpecialCharTok
{
**
}
\DecValTok
{
2
}
\SpecialCharTok
{
\textless
{}
=
}
\DecValTok
{
1
}
\NormalTok
{
)
}
\FunctionTok
{
library
}
\NormalTok
{
(
ggplot
2
)
}
\end
{
Highlighting
}
\end
{
Shaded
}
\begin
{
verbatim
}
## Warning: le package 'ggplot
2
' a été compilé avec la version R
4
.
3
.
3
\end
{
verbatim
}
\begin
{
Shaded
}
\begin
{
Highlighting
}
[]
\FunctionTok
{
ggplot
}
\NormalTok
{
(
df,
}
\FunctionTok
{
aes
}
\NormalTok
{
(
}
\AttributeTok
{
x
=
}
\NormalTok
{
X,
}
\AttributeTok
{
y
=
}
\NormalTok
{
Y,
}
\AttributeTok
{
color
=
}
\NormalTok
{
Accept
))
}
\SpecialCharTok
{
+
}
\FunctionTok
{
geom
\_
point
}
\NormalTok
{
(
}
\AttributeTok
{
alpha
=
}
\NormalTok
{
.
}
\DecValTok
{
2
}
\NormalTok
{
)
}
\SpecialCharTok
{
+
}
\FunctionTok
{
coord
\_
fixed
}
\NormalTok
{
()
}
\SpecialCharTok
{
+
}
\FunctionTok
{
theme
\_
bw
}
\NormalTok
{
()
}
\end
{
Highlighting
}
\end
{
Shaded
}
\includegraphics
{
toy
_
document
_
fr
_
files
/
figure
-
latex
/
unnamed
-
chunk
-
3
-
1
.pdf
}
Il est alors aisé d'obtenir une approximation
(
pas terrible
)
de π en
comptant combien de fois, en moyenne, X
2
+
Y
2
est inférieur à
1
:
\begin
{
Shaded
}
\begin
{
Highlighting
}
[]
\DecValTok
{
4
}
\SpecialCharTok
{
*
}
\FunctionTok
{
mean
}
\NormalTok
{
(
df
}
\SpecialCharTok
{$}
\NormalTok
{
Accept)
}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
## [1] 3.156
\end{verbatim}
\end{document}
mooc-rr.Rproj
0 → 100644
View file @
3acaf1f5
Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX
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