Refactor files

This commit is contained in:
2024-09-18 16:53:09 +02:00
parent cca1c5bd0b
commit a0e242877a
5 changed files with 32 additions and 24 deletions

View File

@@ -0,0 +1,8 @@
# Exercise 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)
```

View File

@@ -0,0 +1,11 @@
# Exercise 2 : Exponential distribution and related distributions
```{r}
n <- 10000
u <- runif(n)
x <- -1/2 * log(1-u)
hist(x, breaks = 50, freq = FALSE)
curve(dexp(x, rate = 2), add = TRUE, col = "red")
qqplot(x, rexp(n, rate = 2))
```

View File

@@ -1,12 +1,3 @@
# Exercise 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)
```
# Exercise 3 : Box Muller Algo
```{r}
@@ -23,5 +14,4 @@ X <- BM(n)
hist(X, breaks = 100, freq = FALSE)
curve(dnorm(x), add = TRUE, col = "red")
```
```

View File

@@ -0,0 +1,12 @@
# Exercise 5 : Simulation of Brownian Motion
```{r}
n <- 1:1100
brownian <- function (i) {
return ((i >= 1 & i <= 100)*(i/100) + (i >= 101 & i <= 110)*(1 + (i - 100)/10) + (i >= 111 & i <= 1110)*(2 + (i - 110)/1000))
}
t <- brownian(n)
W0 <- 0
Wt <- W0 + sqrt(t) * rnorm(1100)
plot(t, Wt, type = "o")
```

View File

@@ -1,13 +0,0 @@
Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX