# Finding the Mean and Variance from PDF

A random variable $n$ can be represented by its PDF

$$p(n) = \frac{(\theta - 1) y^{\theta-1} n}{ (n^2 + y^2)^{(\theta+1)/2}}.$$

$\theta$ is a positive integer and $y$ is a positive parameter. If $\theta=4$ how to you find the mean and variance?

My guess was to plug in $4$ of course and then integrate that function from $0$ to infinity. As for the variance I honestly have no clue. I have not taken statistics in a while so I admit I am a bit rusty. Any clues/help is appreciated. Thanks!

• Presumably $0 \lt n \lt \infty$ and, in general, $\theta \gt 3$ (which does not have to be an integer). Otherwise the variance does not exist. You might want to compare this PDF to that of the F distribution: you will see that $n^2$ has an F distribution and that $y$ is a scale factor. The latter shows you may set $y=1$ and multiply the answer by $y^2$. That reduces the problem to finding the first two moments of the distribution with PDF $3n / (1+n^2)^{5/2}$. BTW, when you integrate it from $0$ to $\infty$ you had better get $1$ as the answer! – whuber Jan 14 '15 at 23:53

I'll give you a few hints that will allow you to compute the mean and variance from your pdf.

First of all, remember that the expected value of a univariate continuous random variable $E[X]$ is defined as $E[X] = \int_{-\infty}^{\infty}{x f(x) dx}$ as explained here, where the range of the integral corresponds to the sample space or support (say, $(-\infty, \infty)$ for a Gaussian distribution, $(0, \infty)$ for an exponential distribution).

Second, the mean of the random variable is simply it's expected value: $\mu = E[X] = \int_{-\infty}^{\infty}{x f(x) dx}$. It looks like you already covered that.

Third, the definition of the variance of a continuous random variable $Var(X)$ is $Var(X) = E[(X-\mu)^2] = \int_{-\infty}^{\infty}{(x-\mu)^2 f(x) dx}$, as detailed here. Again, you only need to solve for the integral in the support. Alternatively, it is sometimes easier to rely on the equivalent expression $Var(X) = E[(X-\mu)^2] = E[X^2] - (E[X])^2$, where the first term is $E[X^2] = \int_{-\infty}^{\infty}{x^2 f(x) dx}$ (see the definition of the expectation in the second paragraph) and the second term is $(E[X])^2 = \mu^2$.

Finally, you don't need to pick an arbitrary value for the parameter $\theta$ and plug it in the pdf. You can solve for the mean and the variance anyway. See, for example, mean and variance for a binomial (use summation instead of integrals for discrete random variables).

If you can't solve this after reading this, please edit your question showing us where you got stuck.

• You provide a very helpful and 101 intro to calculating the first two moments of a distribution. But, given that the OP does not know how to calculate a variance or a mean, do you think it is realistic to expect him to be able to compute the integrals required here, which are not exactly 101, unless we do impose $\theta = 4$? If the person asks: Q. How can I get to the moon? A. Build a space shuttle. If you have any problems, please let me know where you got stuck. – wolfies Jan 15 '15 at 17:02
• @wolfies OP said he integrated his pdf to compute the mean, I don't see why he wouldn't be able to compute the variance. Often at introductory level, it's more difficult to lay out a mathematical problem than to resolve it. – mugen Jan 15 '15 at 17:09
• @Raptors1102 if you can't work out the integrals, just show us where you got stuck and I or someone else will help you sort this out. – mugen Jan 15 '15 at 17:10
• How do you obtain the equalities: $E[(X-\mu)^2] = \int_{-\infty}^{\infty}{(x-\mu)^2 f(x) dx}$ and $E[X^2] = \int_{-\infty}^{\infty}{x^2 f(x) dx}$ Can you point me to a proof of this, or to the property of integrals that is used to prove this? – John Smith Optional Jan 30 '19 at 15:10

In case you get stuck computing the integrals referred to in the above post, here is an automated way to proceed. Given random variable $N$ has pdf $f(n)$: The density is well-defined provided $\theta>1$. The mean $E_f[N]$ is: and the variance of $N$ is: where I am using the Expect and Var functions from the the mathStatica package for Mathematica to automate the nitty-gritties.

In the case of $\theta = 4$, the above results simplify to $E[N] = y$ and $Var(N) = y^2$.