Characterization of a particular integrable function Let $f$ be a strictly positive function such that $\int_{0}^{\infty}f(x)dx=\int_{0}^{\infty}xf(x)=1$ (i.e., a probability density function with expectation one). Let also $g$ be a nonnegative nonconstant function which satisfies $\int_{0}^{\infty}g(ax)f(x)dx=a$, $\forall a>0$. Does this imply that $g(x)=x$ a.e.?
 A: In an earlier revision of your question before you restricted $\mathrm{E}(X)=1$ you wrote 

Does this imply that $g(x)=bx$ for some $b>0$?

I think the answer to this question is yes (with $b=1$ if $\mathrm{E}(X)=1$). Certainly, choosing the form $g(x)=bx$ for $g$ satisfies your integral $\int_{0}^{\infty}g(ax)f(x)dx=a$.
Let $X$ be the random variable with probability density function $f(x)$ as defined in your question, and expectation $\mathrm{E}(X)$. Define $g(x) = bx$, where
$$ b = \frac{1}{\mathrm{E}(X)} $$
Then
$$  \int_0^\infty g(ax)f(x)\;dx$$
$$= \int_0^\infty \frac{1}{\mathrm{E}(X)}axf(x)\;dx$$
$$= \frac{a}{\mathrm{E}(X)} \times \int_0^\infty x f(x)\;dx$$
$$= \frac{a}{\mathrm{E}(X)} \times \mathrm{E}(X) = a$$
To show the implication the other way, which is what you actually asked, you need to show that
$$ \mathrm{E}(g(aX)) = a \;\implies\; g(x) = \frac{x}{\mathrm{E}(X)} $$
To prove that the form for $g(x)$ is the only one possible, it suffices to show
$$ \mathrm{E}(g(aX)) = a\mathrm{E}(X) \;\implies\; g(x) = x $$
because $\mathrm{E}(X)$ is a constant and expectation is linear. Then as $\mathrm{E}(g(aX)) = a\mathrm{E}(X)$ $\implies$ $\mathrm{E}(g(aX)) - a\mathrm{E}(X) = 0$
$$\begin{align}
\int_0^\infty g(ax)f(x) - ax f(x)\;dx &= 0\\
\int_0^\infty (g(ax)-ax)f(x) \;dx &= 0\\
\int_0^\infty (g(u)-u)f(u/a) \;du &= 0\\
\end{align}$$
The only way for this to hold true for all $a$ is for
$$ g(u)-u = 0 \implies g(x) = x $$
This is because if $(g(u)-u)$ were not zero, then whatever the shape of $(g(u)-u)$, it would be possible to scale $f$ using $a$ until the integral became non-zero (note that because $f$ is a probability density it cannot be flat). If $a$ is not allowed to vary then $g(x)=x$ only holds when the probability density is arbitrary (this is because if there were any point where $g(u)-u \neq 0$ it would be possible to construct an $f$ which had a spike around that point and was zero elsewhere).
