I want to show law of large numbers. I simulate a sample of size n=1000, 1000, 10000 respectively from Poisson variates with mean 5, 10, 15, and 20. Then I estimate E(sqrt(x)) and Var(sqrt(x)). My current codes are:

When you pass X and Y to outer, they are replicated to match length of each other. Then for each pair of X and Y, FUN is applied.

If your FUN is not vectorised, it'll take the X and Y as a single input and try to process. But what you want is to apply FUN on each pair independently of other pairs. That's why FUN needs to vectorised, which can be applied on each pair separately. So, what Vectorise does is basically create a new function, which applies your old function on element wise on the cartesian product of the X and Y.