# estimating expected value of a difficult cost function.

#### pemfir

##### New Member
suppose i want to compute the following expectation:
$$E = \int C(x)f(x)dx$$
where x follows a known pdf f(x) from which we can easily draw samples, and C(x) is a function that is very difficult to compute for given x. As a result, i can not solve the integral analytically or numerically. Suppose i can compute C(x) for 10 different realizations of x. Some of these 10 realizations are hand-picked for interesting scenarios that we definitely would like to consider including the mode of f(x). what is the best we can do to estimate E.

I was thinking, i can compute $$f(x_j)$$ at each of those 10 realizations $$\{x_j|j \in 1:10\}$$ (whether they are randomly generated or hand-picked), and then assigned a probability to each of them according to $$p(x_i) = \frac{f(x_i)}{\sum_{j=1:10} f(x_j)}$$ and approximate E using
$$E \approx \sum_{j=1:10} C(x_j)p(x_j)$$

#### rogojel

##### TS Contributor
So, you are approximating your continuous distribution with a discrete one, like using a histogram instead of the graph,. I guess the question will be, how many bars you need and where you place them to capture the shape of the original distribution. I would definitely not pick the xi-s randomly but look at the original shape instead.

I think bootstrapping could help you as well here, to get instead of a single value a range of possible values and an idea of the distribution of the E(x).

regards