# Taking expectations over uniformly distributed random variable

I have a probably very silly question, but somehow I am lost and don't get to the solution. Either it is my mistake or there is a mistake in the paper. Hopefully you can help me out!

The problem is as follows: The density of random variable q that is uniformly distributed between 0 and $\bar{q}$ is given by:

$$\frac{\frac{1+q}{2}}{\frac{2+\bar{q}}{4\bar{q}}}$$

Now taking expectations over q, the paper gets $\frac{\bar{q}(3+2\bar{q})}{3(2+\bar{q})}$. However, if I integrate over above density from 0 to $\bar{q}$, I get $\frac{\bar{q}(2\bar{q}+\bar{q}^2)}{2+\bar{q}}$. It would be really cool, if somebody could either uncover my mistake or conirm my solution. Thanks a lot in advance!

• the density $f(q)$ of $Q$ depends on $q$ and hence contradicts your assertion that the random variable $Q$ is uniformly distributed over $0$ and $\bar{q}$. however, $f(q)$ is indeed a density (if $f(q)=0, q\notin [0,\bar{q}]$) and simple calculations show that $$\mathbb{E}(Q)= \int_{0}^\bar{q} x f(x) \, dx= \frac{\bar{q}(3+2\bar{q})}{3(\bar{q}+2)}.$$ – chRrr Sep 14 '17 at 13:24
• Then your integration is incorrect, because $$\int_0^{\bar q} \frac{1+q}{2}dq = \frac{1}{4}\left(2\bar{q} + \bar{q}^2\right).$$Thus, after dividing by $(2+\bar{q})/(4\bar q)$, your total probability is $\bar{q}^2$. – whuber Sep 14 '17 at 14:27
• @ChRrr Look more carefully at what Wolfram alpha did to your equation before it said it integrated to 1. I agree with whuber's calculation (I also got $\bar{q}^2$ when I did it). – Glen_b Sep 14 '17 at 14:28
• @Glen_b ... and that (strongly) suggests precisely how the paper's formula has been misread in the first place: this appears to be a question about reading algebraic formulas rather than about probability or distributions. There is an important lesson here about reading technical papers, though: one of the first things one should do when presented with the formula for a PDF is to verify that it integrates to unity. (It is surprising how often that simple exercise uncovers typos or misinterpretations.) – whuber Sep 14 '17 at 14:29
• Again, I concur with whuber -- making sure densities integrate to 1 is one of the first things to check when reading a paper (even more fundamental is checking that a density is non-negative, but that's usually pretty obvious). Checking details like that uncovers errors surprisingly often. They not only escape authors, they sometimes escape the review process as well. Sometimes even papers that have been around a long time may have simple, easily spotted errors that nevertheless don't seem to have been picked up. (Even when the paper is correct, checking can help with comprehension) – Glen_b Sep 14 '17 at 14:40