$$\mathrm{E}[g(X)] = \int_{-5}^{5} g(x)p(x)\,\mathrm{d}x.$$
High-density regions matter most. Plot 3 shows each interval's signed contribution; plot 4 adds them from left to right and ends at the expectation.
Densities are renormalized on $[-5,5]$. The δ-like density is a Gaussian with $\sigma=0.02$, so $\mathrm{E}[g(X)]\approx g(\text{location})$. Dragging adds local, linearly interpolated edits to the chosen function. The integral uses 2000 midpoint cells.