# What number minimises RMSD between itself and randomly generated numbers?

Let us assume that we have a random number generator given by its probability density function. Now, we need to use this distribution to generate a number that has the following property. It minimises the root mean square deviation between itself and random numbers generated by the considered distribution.

My question is this number has a special name. May be it is just a mean or median?

• – Macro Jan 28 '13 at 23:50

I think that the mean has the described property. I want to find x that minimises the following expression: (x - x1)^2 + (x - x2)^2 + ... + (x - xn)^2.

To minimise the above expression over x, we take the derivative over x and say that it must be equal to zero:

2*(x - x1) + 2*(x - x2) + ... + 2*(x - xn) = 0

From the above expression we get:

x = (x1 + x2 + ... + xn)/n.

• You are correct. – Jonathan Christensen Jan 28 '13 at 22:17
• This answer is correct. You may also be interested in this answer to a previous question, which shows the same result. – Macro Jan 28 '13 at 23:50
• You don't need Calculus to obtain this result: $X=(x_1, \ldots, x_n)$ is a vector in $\mathbb{R}^n$ and so is $Y=(1, \ldots, 1)$. We work in the plane (or line) generated by these vectors. The Pythagorean Theorem asserts that $(x-x_1)^2 + \cdots + (x-x_n)^2$ is the squared distance between $X$ and $xY$. This is minimized when $X-xY$ is perpendicular to $Y$; that is, their dot product $(X-xY)\cdot Y$ is zero. This implies $X\cdot Y=x(Y\cdot Y)=x(n)$. Since $X\cdot Y = x_1+\cdots+x_n$, we conclude $Y = (x_1+\cdots+x_n)/n$ is the solution: that's the arithmetic mean. – whuber Jan 29 '13 at 4:11