# Standard deviation of a sample when you know the average

I'm coding an app, a part of which is graphing values from a database.

The graph plots the average value of every 10% of the values up to 100% so there are ten points along the x-axis. The graph shows a trend of the lifetime of the stats. Hopefully this makes sense.

I need to decide on a scale for the y-axis of the graph based on the overall average of the values that are graphed. Is there a standard formula I can apply to this average to determine a scale which is likely to ensure that most if not all of the range is covered and appear on said graph?

• Hi, and welcome to CV. I took the liberty of removing your opening sentence; we can see you're new here easily enough (all of use were new here once). – Glen_b -Reinstate Monica Apr 23 '14 at 9:16
• As Glen pointed out, no. However, to solve your problem you can do one of two things. (1) At each iteration, change the scale so that all values fit or (2) scale the mean from the beginning.If you know the database values can't be larger than say, 100, then at each iteration divide the mean by 100. That way you don't have to mess with the y scale every time. – rocinante Apr 23 '14 at 13:48
• Computing the overall average of $n$ values in the database takes $O(n)$ effort. For the same $O(n)$ effort you can simultaneously collect relevant statistics about the spread of the values, such as their range and standard deviation. Why not just do that and use this information to scale the graph? In fact, for $O(1)$ effort you can get decent estimates of the spread (by randomly sampling the data), so there seems to be no practical obstacle to this approach. – whuber Apr 23 '14 at 14:08

Not one that will be of much use, unless the circumstances are very specific (known bounds on the values might help a bit).

To see why no formula will be much use in general:

Let's imagine there's some formula that could be used.

Consider some set of values ($x_1,x_2,\ldots,x_{10},$ with average $\bar x$). I tell you $\bar x$, you have to figure out the range for $x$.

Now consider $y_i=2x_i-\bar x$, which has the same average, but is twice as spread.

Now consider $z_i=100x_i -99\bar x$. 100 times as spread, same average.

So if I give you $\bar x$, do you have the values in $x$, $y$, or $z$? The bounds for $z$ will be useless for $x$ and vice-versa. (How can any any formula tell whether $\bar x$ is the mean of the first, second or third set of values?)

Is it really the case that you only have access to the average? Or is there anything else you either know or can get?