# How to solve this Expectation of log of random variable

This may seem a trivial Question but I am confused and never come across this kind of expression where I need to simplify for a function of a random variable $R$.

I have an expression $E\bigg [\frac{{(\log(R^p)})^2}{N} \bigg]$ where N = number of data points and is a constant; R = is a random variable which is vector of distances from a data point $x$ to its closest neighbor (k nearest neighbor distances); $p$ is the dimension of the data set = 2 in my case.

The way I have solved and got stuck later on is as follows:

$E\bigg [\frac{{(\log(R^p)})^2}{N} \bigg]$

$= E\bigg [\frac{{(p\log(R)})^2}{N} \bigg]$

$= E\bigg [\frac{{p^2(\log(R)})^2}{N} \bigg]$

$= p^2E\bigg [\frac{{(\log(R)})^2}{N} \bigg]$

• One trick that sometimes might help with the expectation of a log of a random variable is to compute its MGF. Commented Jan 30, 2015 at 16:53

There are no general formulas for the expected value of a non-linear function of a random variable. Sometimes it may happen that the non-linear function has a known distribution itself, in which case its expected value has been derived by some good people in the past.

In your case, you are looking at

$$\frac {p^2}{N}E\left[(\log(R))^2 \right]$$

So you have to consider: What is the distribution of $R$? If it is known, then perhaps the distribution of its natural logarithm is also known, say $X = \log R$, or you can derive it. If it is known or you derive it, then maybe its mean and variance become available, $\mu_x, \sigma^2_x$. But then, the expected value you face is the second moment of $X$, and you can calculate it by the relation

$$\sigma^2_x = E(X^2) - \mu_x^2 \implies E(X^2) = \sigma^2_x + \mu_x^2$$

If this approach is intractable, you can explore the possibility of approximating the non-linear function by a linear expansion, although here you should consider the quality of the approximation.

• Thank you for your reply. You did mention that we can derive the distribution. Can you tell me how or point out to a good resource for a beginner in this area?
– SKM
Commented Feb 2, 2015 at 20:48
• If you know the distribution of $R$, then you can apply the "change-of-variables" formula to see what $log R$ looks like. Resources on the formula are all over the web -I tend to prefer something that comes from a university, because they have the educational aspect in mind. Commented Feb 2, 2015 at 21:16
• Thank you. In my case the distribution of R is unknown. This complicates the issue. How to do that?
– SKM
Commented Feb 3, 2015 at 17:44
• If you cannot say something about the distribution of $R$ the you cannot say something about the distribution of a function of $R$, and that's that - you cannot derive theoretical results related to the expected value of interest. of course if there are data, or you can safely simulate the environment, then you can adopt an empirical / Monte Carlo estimation approach. Commented Feb 3, 2015 at 18:32