# Expectation of multivariate function of random variables

How would I define a random variable that is:

• Some random value (uniform distribution) if the magnitude of the difference of the parameters is greater than some threshold $t$
• Otherwise the random variable takes on the value of the first parameter

I'm thinking of something like this:

$$g(x,y) = \left\{ \begin{array}{l l} x & \quad |x-y| < t\\ \text{Random real between 0 and N} & \quad |x-y|>t \end{array} \right.$$

But I have no idea how to actually use this function, for example I want to calculate the expectation of $g(X,Y)$ but I can't figure out a way to do so using my current definition. Really my question is if it is possible to evaluate this integral given my definition of $g(X,Y)$: $$E[g(X,Y)] = \int_{-\infty}^\infty \int_{-\infty}^\infty g(x,y)f_{X,Y}(x,y)\mathrm{d}x\mathrm{d}y$$

where $f_{X,Y}(x,y)$ is the joint PDF of two continuous random variables $X$ and $Y$.

Any suggestions, or recommendations would be greatly appreciated!

$$E[g(X,Y)]=\int\limits_{-\infty}^{\infty}\int\limits_{-\infty}^{\infty}g(x,y)f_{X,Y}(x,y)\mathrm{d}x\mathrm{d}y \\= \int\limits_{-\infty}^{\infty}\int\limits_{y-t}^{y+t}xf_{X,Y}(x,y)\mathrm{d}x\mathrm{d}y + \int\limits_{-\infty}^{\infty}\int\limits_{y+t}^{\infty}Cf_{X,Y}(x,y)\mathrm{d}x\mathrm{d}y + \int\limits_{-\infty}^{\infty}\int\limits_{-\infty}^{y-t}Cf_{X,Y}(x,y)\mathrm{d}x\mathrm{d}y$$
The first integral being justified by the fact that $g(x,y)$ takes on the value x over the area between the lines $y-t$ and $y+t$ and some random value C with PDF $f_C(x)=1/N$ everywhere else.