Move all files
10
Analyse Multidimensionnelle/ADN/.idea/.gitignore
generated
vendored
@@ -1,10 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# GitHub Copilot persisted chat sessions
|
||||
/copilot/chatSessions
|
||||
11
Analyse Multidimensionnelle/ADN/.idea/ADN.iml
generated
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.idea/copilot/chatSessions" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="PROJECT_FILES" />
|
||||
<option name="description" value="" />
|
||||
</component>
|
||||
</project>
|
||||
19
Analyse Multidimensionnelle/ADN/.idea/misc.xml
generated
@@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_20" default="true" project-jdk-name="20" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="RMarkdownSettings">
|
||||
<option name="renderProfiles">
|
||||
<map>
|
||||
<entry key="file://$PROJECT_DIR$/main.rmd">
|
||||
<value>
|
||||
<RMarkdownRenderProfile>
|
||||
<option name="outputDirectoryUrl" value="file://$PROJECT_DIR$" />
|
||||
</RMarkdownRenderProfile>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/ADN.iml" filepath="$PROJECT_DIR$/.idea/ADN.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RGraphicsSettings">
|
||||
<option name="height" value="450" />
|
||||
<option name="resolution" value="75" />
|
||||
<option name="version" value="2" />
|
||||
<option name="width" value="720" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RMarkdownGraphicsSettings">
|
||||
<option name="globalResolution" value="75" />
|
||||
<option name="version" value="2" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RSettings">
|
||||
<option name="interpreterPath" value="/usr/local/bin/R" />
|
||||
<option name="loadWorkspace" value="true" />
|
||||
<option name="saveWorkspace" value="true" />
|
||||
</component>
|
||||
</project>
|
||||
6
Analyse Multidimensionnelle/ADN/.idea/vcs.xml
generated
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
10
Analyse Multidimensionnelle/DM ACP/.idea/.gitignore
generated
vendored
@@ -1,10 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# GitHub Copilot persisted chat sessions
|
||||
/copilot/chatSessions
|
||||
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="PROJECT_FILES" />
|
||||
<option name="description" value="" />
|
||||
</component>
|
||||
</project>
|
||||
19
Analyse Multidimensionnelle/DM ACP/.idea/misc.xml
generated
@@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_20" default="true" project-jdk-name="20" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="RMarkdownSettings">
|
||||
<option name="renderProfiles">
|
||||
<map>
|
||||
<entry key="file://$PROJECT_DIR$/DM_ACP.Rmd">
|
||||
<value>
|
||||
<RMarkdownRenderProfile>
|
||||
<option name="outputDirectoryUrl" value="file://$PROJECT_DIR$" />
|
||||
</RMarkdownRenderProfile>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/DM ACP.iml" filepath="$PROJECT_DIR$/.idea/DM ACP.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RGraphicsSettings">
|
||||
<option name="height" value="450" />
|
||||
<option name="resolution" value="75" />
|
||||
<option name="version" value="2" />
|
||||
<option name="width" value="720" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RMarkdownGraphicsSettings">
|
||||
<option name="globalResolution" value="75" />
|
||||
<option name="version" value="2" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RSettings">
|
||||
<option name="interpreterPath" value="/usr/local/bin/R" />
|
||||
</component>
|
||||
</project>
|
||||
6
Analyse Multidimensionnelle/DM ACP/.idea/vcs.xml
generated
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
8
Analyse Multidimensionnelle/TP1/.idea/.gitignore
generated
vendored
@@ -1,8 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
9
Analyse Multidimensionnelle/TP1/.idea/TP1.iml
generated
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="PROJECT_FILES" />
|
||||
<option name="description" value="" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,12 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||
<option name="ignoredErrors">
|
||||
<list>
|
||||
<option value="N806" />
|
||||
</list>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
||||
19
Analyse Multidimensionnelle/TP1/.idea/misc.xml
generated
@@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_20" default="true" project-jdk-name="20" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="RMarkdownSettings">
|
||||
<option name="renderProfiles">
|
||||
<map>
|
||||
<entry key="file://$PROJECT_DIR$/TP2_Enonce_2024.Rmd">
|
||||
<value>
|
||||
<RMarkdownRenderProfile>
|
||||
<option name="outputDirectoryUrl" value="file://$PROJECT_DIR$" />
|
||||
</RMarkdownRenderProfile>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/TP1.iml" filepath="$PROJECT_DIR$/.idea/TP1.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RGraphicsSettings">
|
||||
<option name="height" value="450" />
|
||||
<option name="resolution" value="75" />
|
||||
<option name="version" value="2" />
|
||||
<option name="width" value="720" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RMarkdownGraphicsSettings">
|
||||
<option name="globalResolution" value="75" />
|
||||
<option name="version" value="2" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RSettings">
|
||||
<option name="interpreterPath" value="/usr/local/bin/R" />
|
||||
</component>
|
||||
</project>
|
||||
6
Analyse Multidimensionnelle/TP1/.idea/vcs.xml
generated
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,167 +0,0 @@
|
||||
---
|
||||
title: "TP4 Enoncé"
|
||||
output:
|
||||
pdf_document: default
|
||||
html_document: default
|
||||
---
|
||||
|
||||
```{r setup, include=FALSE}
|
||||
knitr::opts_chunk$set(echo = TRUE)
|
||||
```
|
||||
|
||||
|
||||
Nous allons étudier un exemple qui porte sur les exploitations agricoles de la région Midi-Pyrénées. Les données proviennent des “Tableaux Economiques de Midi-Pyrénées”, publiées par la Direction Régionale de Toulouse de l’INSEE, en 1996.
|
||||
|
||||
Le tableau de contingence provient du croisement de deux variables, Département (8 modalités) et S.A.U (Surface Agricole Utilisée, 6 classes). Notez que cette dernière est une variable continue discrétisée.
|
||||
|
||||
Voici les abréviations :
|
||||
|
||||
Pour les départements
|
||||
|
||||
ARIE= Ariège, AVER: Aveyron, H.G. = Haute-Garonne, GERS, LOT, H.P. = Hautes-Pyrénées, TARN, T.G. = Tarn et Garonne.
|
||||
|
||||
Pour les S.A.U
|
||||
|
||||
INF05: moins de 5 hectares, S0510: entre 5 et 10 hectares etc..., SUP50: plus de 50 hectares.
|
||||
|
||||
1) Importer le tableau de contingence. Appeler le depsau.
|
||||
|
||||
```{r}
|
||||
library(FactoMineR)
|
||||
|
||||
rm(list=ls())
|
||||
|
||||
depsau <- read.table("depsau.csv", sep=";",header=TRUE, row.names=c("X"))
|
||||
```
|
||||
|
||||
|
||||
|
||||
2) L'étude porte sur combien d'exploitations agricoles ?
|
||||
|
||||
```{r}
|
||||
n = sum(depsau)
|
||||
print(c("l'étude porte sur",n,"exploitations"),quote=FALSE)
|
||||
```
|
||||
|
||||
|
||||
3) Afin d'étudier la liaison entre les variables Département et S.A.U. réalisez un test du khi-2 d'indépendance au seuil d'erreur 5% (bien écrire le test complètement sur votre copie avec les hypothèses etc.). Vous pourrez utiliser la fonction chisq.test
|
||||
|
||||
```{r}
|
||||
chi <- chisq.test(depsau)
|
||||
chi$statistic
|
||||
```
|
||||
```{r}
|
||||
tobs <- sum((depsau - chi$expected)**2/chi$expected)
|
||||
tobs
|
||||
```
|
||||
```{r}
|
||||
quantile <- qchisq(0.95,(dim(depsau)[1]-1)*(dim(depsau)[2]-1))
|
||||
quantile
|
||||
```
|
||||
|
||||
```{r}
|
||||
chi
|
||||
```
|
||||
|
||||
4) Afficher le tableau des effectifs observés. Vous pourrez utiliser la fonction summary et la question 3.
|
||||
|
||||
```{r}
|
||||
par(mar =c(a=6,b=6,c=6,d=6))
|
||||
barplot(t(chi$observed),beside = TRUE, col = rainbow(6),main = "Observés")
|
||||
```
|
||||
|
||||
|
||||
5) Afficher le tableau des effectifs attendus sous l'hypothèse d'indépendance entre les deux variables. Vous pourrez utiliser la fonction summary et la question 3.
|
||||
|
||||
```{r}
|
||||
par(mar =c(a=6,b=6,c=6,d=6))
|
||||
barplot(t(chi$expected),beside = TRUE, col = rainbow(6),main = "Observés")
|
||||
```
|
||||
|
||||
|
||||
6) Calculer le tableau des contributions au chi-2. Commenter.
|
||||
|
||||
```{r}
|
||||
contrib <- round(((depsau - chi$expected)**2/chi$expected) * 100/tobs,digits = 2)
|
||||
```
|
||||
|
||||
```{r}
|
||||
```
|
||||
|
||||
7) Calculer le tableau des probabilités associé au tableau de contingence.
|
||||
|
||||
```{r}
|
||||
prob <- depsau/n
|
||||
```
|
||||
|
||||
|
||||
8) Calculer les probabilités marginales des lignes. On pourra utiliser la fonction apply.
|
||||
|
||||
|
||||
```{r}
|
||||
marg.ligne <- apply(prob,MARGIN = 1,FUN = sum)
|
||||
```
|
||||
|
||||
9) Calculer le tableau des profils lignes et le profil moyen associé. Commenter.
|
||||
|
||||
```{r}
|
||||
prof.ligne <- prob / marg.line
|
||||
```
|
||||
|
||||
```{r}
|
||||
prof.ligne.moyen <- apply(prob,2,sum)
|
||||
```
|
||||
|
||||
|
||||
|
||||
10) Calculer les probabilités marginales des colonnes.
|
||||
|
||||
|
||||
```{r}
|
||||
marg.col <- prof.ligne.moyen
|
||||
```
|
||||
|
||||
|
||||
11) Calculer le tableau des profils colonnes et le profil moyen associé.
|
||||
|
||||
```{r}
|
||||
prof.col <- t(t(prob) / marg.col)
|
||||
```
|
||||
|
||||
```{r}
|
||||
prof.col.moyen <- marg.ligne
|
||||
```
|
||||
|
||||
|
||||
12) Lancer une AFC avec FactoMineR sur depsau.
|
||||
|
||||
|
||||
```{r}
|
||||
|
||||
res.depsau<-CA(depsau)
|
||||
|
||||
summary(res.depsau)
|
||||
|
||||
eig.val <- res.depsau$eig
|
||||
barplot(eig.val[, 2],
|
||||
names.arg = 1:nrow(eig.val),
|
||||
main = "Variances Explained by Dimensions (%)",
|
||||
xlab = "Principal Dimensions",
|
||||
ylab = "Percentage of variances",
|
||||
col ="steelblue")
|
||||
# Add connected line segments to the plot
|
||||
#lines(x = 1:nrow(eig.val), eig.val[, 2],
|
||||
# type = "b", pch = 19, col = "red")
|
||||
|
||||
plot(res.depsau, invisible = "row")
|
||||
plot(res.depsau, invisible = "col")
|
||||
|
||||
```
|
||||
13) Combien d'axes factoriels y-a-t-il à calculer ?
|
||||
|
||||
Le nombre d'axes factoriels a calculer est min(I-1,J-1) avec I le nombre de lignes et J le nombres de colones. Il y en a donc 5. Cependant, par le critère du coude, on en concerve que 2.
|
||||
|
||||
14) Faire l'étude statistique complète.
|
||||
|
||||
Le premier axe range les espaces agricoles selon leur superficie et les régions selon le nombres de espaces agricoles ayant la même taille.
|
||||
Le second axe range les régions selon leur concentration en espaces agricole extrême.
|
||||
@@ -31,10 +31,11 @@ HairEyeColor
|
||||
```
|
||||
```{r}
|
||||
data <- apply(HairEyeColor, c(1, 2), sum)
|
||||
n <- sum(data)
|
||||
data
|
||||
```
|
||||
```{r}
|
||||
barplot(data,beside=TRUE,legend.text =rownames(data),main=" Effectifs observés",col=c("black","brown","red","yellow"))
|
||||
barplot(data,beside=TRUE,legend.text =rownames(data),main="Effectifs observés",col=c("black","brown","red","yellow"))
|
||||
```
|
||||
|
||||
1) Commentez le barplot ci-dessus ? S'attend on à une situation d'indépendance ?
|
||||
@@ -58,7 +59,7 @@ contrib_moy
|
||||
4) Calculer le tableau des contributions au khi-deux
|
||||
|
||||
```{r}
|
||||
contribs <- (test$observed - test$expected)**2 / test$expected / test$statistic * 100
|
||||
contribs <- (test$observed - test$expected)**2 / test$expected * 100/test$statistic
|
||||
contribs
|
||||
```
|
||||
5) Calculer le tableau des probabilités associé au tableau de contingence.
|
||||
@@ -75,6 +76,10 @@ prob
|
||||
marginale_ligne <- apply(prob, 1, sum)
|
||||
profil_ligne <- prob / marginale_ligne
|
||||
profil_ligne_moyen <- apply(prob, 2, sum)
|
||||
|
||||
marginale_ligne
|
||||
profil_ligne
|
||||
profil_ligne_moyen
|
||||
```
|
||||
|
||||
7) Calculer le tableau des profils colonnes et le profil moyen associé.
|
||||
@@ -82,6 +87,10 @@ profil_ligne_moyen <- apply(prob, 2, sum)
|
||||
marginale_colonne <- apply(prob, 2, sum)
|
||||
profil_colonne <- t(t(prob) / marginale_colonne)
|
||||
profil_colonne_moyen <- apply(prob, 1, sum)
|
||||
|
||||
marginale_colonne
|
||||
profil_colonne
|
||||
profil_colonne_moyen
|
||||
```
|
||||
|
||||
8) Que vaut l’inertie du nuage des profils lignes ? Celle du nuage des profils colonnes ?
|
||||
@@ -167,7 +176,7 @@ contrib_moy_house
|
||||
4) Calculer le tableau des contributions au khi-deux
|
||||
|
||||
```{r}
|
||||
contrib_house <- (test_house$observed - test_house$expected)**2 / test_house$expected / test_house$statistic * 100
|
||||
contrib_house <- (test_house$observed - test_house$expected)**2 / test_house$expected * 100/test_house$statistic
|
||||
contrib_house
|
||||
```
|
||||
5) Calculer le tableau des probabilités associé au tableau de contingence.
|
||||
@@ -182,12 +191,20 @@ proba_house
|
||||
marginale_ligne <- apply(proba_house, 1, sum)
|
||||
profil_ligne <- proba_house / marginale_ligne
|
||||
profil_ligne_moyen <- apply(proba_house, 2, sum)
|
||||
|
||||
marginale_ligne
|
||||
profil_ligne
|
||||
profil_ligne_moyen
|
||||
```
|
||||
7) Calculer le tableau des profils colonnes et le profil moyen associé.
|
||||
```{r}
|
||||
marginale_colonne <- apply(proba_house, 2, sum)
|
||||
profil_colonne <- t(t(proba_house) / marginale_colonne)
|
||||
profil_colonne_moyen <- apply(proba_house, 1, sum)
|
||||
|
||||
marginale_colonne
|
||||
profil_colonne
|
||||
profil_colonne_moyen
|
||||
```
|
||||
8) Que vaut l’inertie du nuage des profils lignes ? Celle du nuage des profils colonnes ?
|
||||
|
||||
|
Before Width: | Height: | Size: 199 KiB After Width: | Height: | Size: 199 KiB |
|
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 114 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
13
M1/Monte Carlo Methods/Monte Carlo Methods.Rproj
Normal file
@@ -0,0 +1,13 @@
|
||||
Version: 1.0
|
||||
|
||||
RestoreWorkspace: Default
|
||||
SaveWorkspace: Default
|
||||
AlwaysSaveHistory: Default
|
||||
|
||||
EnableCodeIndexing: Yes
|
||||
UseSpacesForTab: Yes
|
||||
NumSpacesForTab: 2
|
||||
Encoding: UTF-8
|
||||
|
||||
RnwWeave: Sweave
|
||||
LaTeX: pdfLaTeX
|
||||
25
M1/Monte Carlo Methods/TP1-Test.rmd
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
title: "R Notebook"
|
||||
output: html_document
|
||||
---
|
||||
|
||||
The [R plugin](https://www.jetbrains.com/help/pycharm/r-plugin-support.html) for IntelliJ-based IDEs provides
|
||||
handy capabilities to work with the [R Markdown](https://www.jetbrains.com/help/pycharm/r-markdown.html) files.
|
||||
To [add](https://www.jetbrains.com/help/pycharm/r-markdown.html#add-code-chunk) a new R chunk,
|
||||
```{r}
|
||||
|
||||
```
|
||||
position the caret at any line or the code chunk, then click "+".
|
||||
|
||||
The code chunk appears:
|
||||
```{r}
|
||||
```
|
||||
|
||||
Type any R code in the chunk, for example:
|
||||
```{r}
|
||||
mycars <- within(mtcars, { cyl <- ordered(cyl) })
|
||||
mycars
|
||||
```
|
||||
|
||||
Now, click the **Run** button on the chunk toolbar to [execute](https://www.jetbrains.com/help/pycharm/r-markdown.html#run-r-code) the chunk code. The result should be placed under the chunk.
|
||||
Click the **Knit and Open Document** to build and preview an output.
|
||||
27
M1/Monte Carlo Methods/TP1.Rmd
Normal file
@@ -0,0 +1,27 @@
|
||||
# Exercice 1 : Uniform
|
||||
|
||||
```{r}
|
||||
n <- 10e4
|
||||
U <- runif(n)
|
||||
X <- 5 * (U <= 0.4) + 6 * (0.4 < U & U <= 0.6) + 7 * (0.6 < U & U <= 0.9) + 8 * (0.9 < U)
|
||||
barplot(table(X)/n)
|
||||
```
|
||||
|
||||
# Exercice 3 : Box Muller Algo
|
||||
|
||||
```{r}
|
||||
BM <- function(n) {
|
||||
U1 <- runif(n)
|
||||
U2 <- runif(n)
|
||||
X1 <- sqrt(-2 * log(U1)) * cos(2 * pi * U2)
|
||||
X2 <- sqrt(-2 * log(U1)) * sin(2 * pi * U2)
|
||||
return(c(X1, X2))
|
||||
}
|
||||
|
||||
n <- 10e4
|
||||
X <- BM(n)
|
||||
|
||||
hist(X, breaks = 100, freq = FALSE)
|
||||
curve(dnorm(x), add = TRUE, col = "red")
|
||||
```
|
||||
|
||||
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 19 KiB |