TU Wien:Statistik und Wahrscheinlichkeitstheorie UE (Levajkovic)/Übungen 2023W/HW07.5
Zur Navigation springen
Zur Suche springen
- Law of large numbers
Visualize the law of the large numbers assuming exponential distributed random variables. Let be i.i.d. random variables, with .
For the mean of the first random variables is given as
Further, for a sequence of means is given as . Assume and and plot 20 realized sequences of means in one graph. Mark the expectation of . Comment on the obtained result.
Dieses Beispiel ist als solved markiert. Ist dies falsch oder ungenau? Aktualisiere den Lösungsstatus (Details: Vorlage:Beispiel)
Lösungsvorschlag von Lessi[Bearbeiten | Quelltext bearbeiten]
--Lessi 2024-02-07T13:04:11Z
# Visualize the law of the large numbers assuming exponential distributed random variables.
# Let X1, X2, . . . be i.i.d. random variables, with X1 ∼ exp(λ).
n <- 200
lambda <- 0.5
exp <- 1 / lambda
seqs <- 20
color_palette <- rainbow(seqs)
plot(exp, type = "n", xlab = "n", ylab = expression(bar(X)[n]), xlim=c(1, 200), ylim=c(0, 2*exp))
abline(h = exp, lty=2)
for (i in 0:seqs) {
sequence <- c()
for (m in seq(1:n)) {
X <- rexp(m, lambda)
sequence[m] = (1 / m) * sum(X)
}
lines(1:n, sequence, col=color_palette[i])
}