Могу ли я спросить, знает ли кто-то еще, что не так на графике кривой, чтобы он не отображался на графике для Приблизительной суммы показателей? Спасибо!
Пусть $ {\ cal S} = {X_1, X_2, \ ldots, X_ {100}} $ - случайная выборка размером $ n = 100 $ из экспоненциального распределения с параметром скорости $ r = 1 $. Напомним, что все случайные величины в случайной выборке являются независимыми. Тогда ожидаемое значение каждого из $ X_i $ равно 1:
$$
\hbox{E}[X_i]\ =\ 1,\ \ i = 1, 2, \dots, 100
$$
Similarly, the variance of each of the $X_i$ is 1:
$$
\hbox{Var}[X_i]\ =\ 1,\ \ i = 1, 2, \dots, 100
$$
Now consider the sum random variable $S = X_1 + X_2 + \ldots + X_n$. We haven't discussed any theorems about sums of exponential random variables, so we don't know what the distribution of the random variable $S$ is. However, we can use our general theorems about sums of independent random variables to determine the expected value and variance of $S$.
construct a simulation to draw random values of $S$. For each iteration of the `for` loop, you should:
* First, use the built-in R probability function `rexp()` to generate a random sample of 100 values from an exponential distribution with a rate parameter of $r = 1$.
* Next, use the built-in R function `sum()` to calculate the sum of the values in the random sample.
* Finally, store this sum in the `outcome.vector`.
When the `for` loop finishes, the `outcome.vector` will be populated with random values from the distribution of $S$.
Once you've run your simulation, construct a histogram of the values. Does the distribution of values look like anything that we've seen so far?
number.of.replications <-10000
outcome.vector <- numeric(number.of.replications)
for (replication.index in 1: number.of.replications) {
random.sample <-rexp(n=100,rate=1)
random.sample.sum <-sum(random.sample)
outcome.vector[replication.index] <-random.sample.sum
}
hist (outcome.vector,
prob=TRUE,
main="Histogram of exponential sample",
xlab="x",
ylab="Density",
col="skyblue",
breaks=50
)
curve(
rate.parameter^2*x*exp(-rate.parameter*x),
lty="dashed",
lwd=3,
col="navy",
add=TRUE
)
введите описание изображения здесь