I am trying to compute an expected value using simulation. I have a random number x with density function d[x]. I want to compute the expected value of function f[x], which is equal to the integral of f[x] times d[x] over x. In my case, it is difficult to compute the integral so I simulate N values for x and compute the average of f[x] over all N simulated values.
My problem is that my code takes to long for my purposes: this is a part of a larger program and is making it unfeasible in terms of time.
The following code provides an example of the situation, and my question is how could I reduce the time this takes. THanks a lot for your help