I set the seed at 740, generated m=1050 samples of dimension n, where n∈{100,200,300,…,2500}, with Exponential distribution of expected value 1/λ=1/2.5.
mic <- function(seed, m, n, lambda, gama) {
set.seed(seed)
return(mean(replicate(m, (2*(qnorm((1+gama)/2)/sqrt(n)))/(mean(rexp(n ,lambda))))))
}
n= seq(100,5000,100)
mic_values = sapply(n, \(n) mic(seed=740,m=1050,n=n, lambda=2.5, gama=0.95))
ggplot(NULL, aes(x=n, y=mic_values)) +
geom_point() +
geom_line()
In the generated samples i want to replace any ϵ×100%=20% of the observations from each sample with others generated from a population that models the distribution of outliers, Xc, (lets say Xc∼Exp(λc=0.02)). For each of the samples generated without "contamination" (respectively, with contamination), how do I construct an approximate confidence interval for the inverse of the expected value. (lets consider a confidence level (1−α)=0.95)?
For each value of n, how can i calculate the Mean Amplitude of the m=1050 confidence intervals: MA(n), in case of samples generated without contamination and MAc(n), in case of contamination?
And finally how could i construct a graph placing the sample size, n, on the xx-axis and the values of MA(n) and MAc(n) on the y-axis??