I have a problem with my statistics task. It sounds like this: "Using the Monte Carlo method, plot the dependence of a on b for a from -5 to 5, where $P (a < x-y < b) = 0.95$, where $x\sim N(0,1)$, and y is a uniformly distributed random variable from -2 to 2." what should I do, where to start? until I have no ideas.
To be honest, I did not understand anything in the following answer: "First find the probability distribution of random variable X−Y using montecarlo method.
1.Pick an x and y randomly according to their densities and then compute x−y. Do this N times.
2.Make a list x−y values.
3.Sort the list in ascending order.
4.Fix an b which is in [−5,5].
5.From count number of values less than b, call this k.
$\cdot$ If k/N>0.95: Count from smallest value till you get the k/N less more or less equal to 0.95. The value you find is the a
$\cdot$ If k/N<0.95:
No such a exists."
I tried to code it and I have a lot of questions.
First of all, I created a list for $x-y$.
dif<-x-y
Then, I created a list of values of a, which is from -5 to 5
a<-seq(-5, 5, 0.05)
But now I must go to the 5-th item. It sounds like this: From count number of values more than a, call this k. What should I do here? I must take values from $x-y$, which are more than a? Then I should count $k/N$ and if it is more than 0.95 what is next? "Count from smallest value", but what smallest value?
Thanks for help