I have a problem with trajectories $x(t)$ where $x(0) = x(T) = 0$ and $x > 0$ for all $t \in [0, T]$.
I know the joint probability $P(x, t)$ and can find the expected $\left\langle x(t) \right\rangle$ simply as $$\left\langle x(t) \right\rangle = \int_0^\infty x P(x, t) \, \mathrm{d} x$$ or maybe in a limited case approximate it as $$\left\langle x(t) \right\rangle = \int_0^{x_{max}} x P(x, t) \, \mathrm{d} x~.$$
However if I have an additional constraint such that $$a < \int_0^T x(t) \, \mathrm{d} t < b$$ I don't know how I should start finding the expected value (with this constraint).
I would be happy with just a numerical solution.
In this case I would calculate $P(x_i, t_j)$ in a grid of $x_i = i \Delta x$ and $t_j = j \Delta t$ values where $$i \in \{0, 1, \cdots, N\}~,$$ $$\Delta x = \frac{x_{max}}{N}~,$$ $$j \in \{0, 1, \cdots, M\}$$ and $$\Delta t = \frac{T}{M}~.$$
But even here I'm not sure how I would enforce the constraint in finding the approximate expected value.
EDIT: As a commenter pointed out, I probably should also have some regularity constraints on the trajectories, such as $$\left|\frac{\mathrm{d} x}{\mathrm{d} t}\right| < c \mathrm{.}$$ Any help on how to approach this problem would be helpful.
To obtain a Monte Carlo estimate, simply sample $n$ paths $\{x_i(t)\}_{i=1}^n$, and then the estimate is $$\bar{x}(t) \stackrel{\text{def}}{=} \frac{1}{\hat{p}}\frac{1}{n}\sum_{i=1}^n x_i(t) \boldsymbol{1}\left( a < \int_0^t x_i(t)\,dt < b\right),$$ where $\boldsymbol{1}(\cdot)$ is the indicator function, and $$\hat{p} = \frac{1}{n} \sum_{i=1}^n \boldsymbol{1}\left( a < \int_0^t x_i(t)\,dt < b\right).$$
The indicator function is equal to 1 if the inequalities are satisfied and 0 otherwise. To estimate the integral, you can use the trapezoidal rule. To see where the above formula came from, look at the Wikipedia page on conditional expectations, specifically the third equation in the section Conditional expectation with respect to an event.
If the indicator is almost always 1 or 0 and $n$ is not large enough, then your estimates will not be very accurate. The error also depends on how variable the paths are at each time point.
The above method should work fine if the paths are not too wild. By which I mean the variance at each time point is finite and they don't "wiggle" too much.