diff options
| Commit | 1426e4a759655f69f40ca5fa2a41440fdabd1ee3 (patch) | |
|---|---|---|
| Author | 2024-04-17 20:14:40 +0300 | |
| Committer | 2024-04-17 20:14:40 +0300 | |
| Files | 4ca1f718f943d7ae84feea32b047a37ffe39a64c /Year 3/Statistics/hw1.r | |
| uni-projects-1426e4a759655f69f40ca5fa2a41440fdabd1ee3.tar uni-projects-1426e4a759655f69f40ca5fa2a41440fdabd1ee3.tar.gz uni-projects-1426e4a759655f69f40ca5fa2a41440fdabd1ee3.zip | ||
| Parent | 5856b28e64b1c3ef39d34c032275f9550e6ac983 (diff) | |
[S/hw1] Updated from dnorm to pnorm
1 files changed, 5 insertions, 5 deletions
| -rw-r--r-- | Year 3/Statistics/hw1.r | 10 |
diff --git a/Year 3/Statistics/hw1.r b/Year 3/Statistics/hw1.r index ec9f021..afb1be3 100644 --- a/Year 3/Statistics/hw1.r +++ b/Year 3/Statistics/hw1.r @@ -19,7 +19,7 @@ ex1 <- function(total = 24, marked = 4, boxes = 4, iterations = 10000) { ex1() ex2 <- function(n, lambda = 1/5, N = 10000, mu = 5, sigma = 5 / sqrt(n)) { - x <- function() rexp(n, rate=lambda) + x <- function() rexp(n, rate=lambda) xdash <- replicate(N, sum(x()) / n) fchapeau <- function(t) { @@ -28,12 +28,12 @@ ex2 <- function(n, lambda = 1/5, N = 10000, mu = 5, sigma = 5 / sqrt(n)) { return (1/N * sum(I(xdash <= t))) } - t <- seq(0, 10, by=0.1) + t <- seq(2, 8, by=0.1) Fpoints <- sapply(t, fchapeau) - Npoints <- sapply(t, function(t) dnorm(t, mu, sigma)) + Npoints <- sapply(t, function(t) pnorm(t, mu, sigma)) - plot (t, Fpoints, type="l", ylim=c(0, 1.1)) - lines(t, Npoints, lty=2) + plot (t, Fpoints, type="l") + lines(t, Npoints, lty=2, col="darkred") } ex2(30) |
