The expected value of a random function

Suppose we have a 'random function' $$f(x)$$ that will be one of $$n$$ functions $$f_1(x), ..., f_n(x)$$ with probabilities $$p_1, ..., p_n$$. Intuitively, it might seem sensible to define

$$E[f(x)] = \sum_{i=1}^{n}f_i(x)p_i$$

Now suppose $$f(x)$$ can be any one of a continuum of functions, each indexed by a unique real number. Again, it might seem sensible to define

$$E[f(x)] = \int_{-\infty}^{\infty}f_i(x)g(i)di$$

where $$g(i)$$ describes the probability densities of the different possible functions.

However, I cannot find such expressions anywhere; and when I Google 'functional integration' I find rather more complicated notions than those expressed here.

Is there some reason why the definitions above are invalid/problematic? To be clear, I understand that the set of real valued functions is larger than the set of real numbers. So if all real valued functions had positive probability, it would not be possible to index them with the real numbers as I have done here. However, suppose we somehow knew that there were only a continuum of functions with positive probability: could we then define the expected value of the function as above?

• I don't know why there would be a problem. You're just defining a real number $f(x)$ for each $x$ by taking the expected value of some random variable – mathworker21 Jan 11 at 18:24
• Also, you should write $E[f(x)] = \int_{-\infty}^\infty f_t(x)g(t)dt$ – mathworker21 Jan 11 at 18:24
• I mean, of course for the integral defn of $E[f(x)]$, you must make sure $t \mapsto f_t(x)g(t)$ is measurable or whatever – mathworker21 Jan 11 at 18:39
• Another way to see this: You have a real-valued function $f(x, \omega)$ for $x \in \mathbb{R}$ and $\omega \in S$ (where $S$ is the sample space). So for each $x \in \mathbb{R}$ you can define random variable $Y_x:S\rightarrow\mathbb{R}$ by $Y_x(\omega)=f(x,\omega)$. Its expectation $E[Y_x]$ is defined as usual for random variables. Since the $x$ parameter determines properties of $Y_x$, the expectation $E[Y_x]$ may depend on $x$. We would also need to assume the standard things for random variables, that is for each $x$ assume $Y_x$ has a CDF $P[Y_x\leq y]$ for all $y \in \mathbb{R}$. – Michael Jan 11 at 21:19