[I will speculate about what you are trying to approximate by simulation.
At least the following will show one format for simulation in R that you may be
able to adapt to your work in Python.]
Suppose an individual flood has $X \sim \mathsf{Norm}(\mu=5,\, \sigma=0.2).$
And suppose you want to know about the average $A =\bar X_{1000}$ of $n = 1000$ floods; in particular, you want to find $P(A > 5.01).$
Then the exact theoretical answer can be found by using the distribution of $A,$
which is $$A \sim \mathsf{Norm}(\mu = 5,\, \sigma=.2/\sqrt{1000}).$$
By a direct computation in R, where pnorm
is a normal CDF, we find
$P(A > 5.01) = 1 - P(A \le 5.01) = 0.0569:$
1 - pnorm(5.01, 5, .2/sqrt(1000))
[1] 0.05692315
Now suppose you are not yet familiar with the relationship for the distribution of $A,$ displayed above. And you are asked to do a simulation
to approximate $P(A > 5.01).$
There are various formats for doing such a simulation in R. I will illustrate one of them. A thousand iterations is not enough to get reasonable
accuracy, so I will use 100,000. Thus, the vector a
will contain 100,000
simulated averages. The result is $P(A > 5.01) = 0.0575 \pm 0.0007.$
set.seed(2021)
a = replicate(10^5, mean(rnorm(1000, 5, .2)))
summary(a); length(a); sd(a)
Min. 1st Qu. Median Mean 3rd Qu. Max.
4.973 4.996 5.000 5.000 5.004 5.026
[1] 100000 # sample size
[1] 0.006326662 # sample SD
mean(a > 5.01)
[1] 0.05749 # aprx P(A > 5.01)
sd(a > 5.01)/sqrt(10^5)
[1] 0.0007361076 # aprx 95% margin of sim error
The logical vector a > 5.01
has 100,000 TRUE
s and FALSE
s; its mean
is the proportion of its TRUE
s.
hist(a, prob=T, br=40, col="skyblue2",
main="Histogram of simulated Averages")
curve(dnorm(x, 5, .2/sqrt(1000)), add=T, col="orange", lwd=2)
abline(v = 5.01, lty="dotted", lwd=2)