This commit is contained in:
2024-10-09 14:46:22 +02:00
parent fc0b87a405
commit aeb5314b8b
3 changed files with 5 additions and 9 deletions

View File

@@ -42,5 +42,5 @@ for (j in (1:n)) {
i <- 1
}
hist(S, freq = FALSE)
# curve(dpois(S, lambda = 4), add = TRUE, col = "red")
curve(dpois(S, lambda = 4), add = TRUE, col = "red")
```

View File

@@ -12,6 +12,6 @@ BM <- function(n) {
n <- 10e4
X <- BM(n)
hist(X, breaks = 100, freq = FALSE)
hist(X, breaks = 50, freq = FALSE)
curve(dnorm(x), add = TRUE, col = "red")
```

View File

@@ -2,21 +2,17 @@
```{r}
f <- function(x) {
return(
(2 / pi * sqrt(1 - x^2)) * (x >= -1 & x <= 1)
)
2 / pi * sqrt(1 - x^2) * (x >= -1 & x <= 1)
}
n <- 10000
M <- 4 / pi
g <- function(x) {
return(
1 / 2 * (x >= -1 & x <= 1)
)
1 / 2 * (x >= -1 & x <= 1)
}
x <- NULL
x <- numeric(0)
while (length(x) < n) {
U <- runif(1)
X <- runif(1, -1, 1)