# Tightest bounds on sample variance given sample size, mean, minimum, and maximum

For real-valued samples (possibly known to lie in some interval, but without further constraints on them), I am interested in the tightest possible bound on the sample variance $\sigma^2$, given the sample size $n$, sample mean $\mu$, sample minimum $m$, and sample maximum $M$. The context is that of data-sets with these statistics and the sample standard deviation. Namely, tuples $(m, M, \mu, \sigma)$ with $n$ fixed. Their use would be to check the consistency of these values. (You would be amazed to see what errors appear in such datasets!)

I have come across the lower bound attributed to Gyula (Julius) von Szőkefalvi Nagy,

$$\sigma^2\geq\frac{1}{n}\frac{M-m}{2},$$

but have not identified this bound in the claimed source or an academic reference; I assume that $n$ needs to be replaced by $n-1$ if Bessel's correction is used.

I have come across the upper bound named after Bathia and Davis,

$$\sigma^2\leq(M-\mu)(\mu-m).$$

Their paper “A Better Bound on the Variance” is easy to locate.

However, neither bound is claimed to be the tightest possible given $n$, $\mu$, $m$, and $M$. A priori, this seemed unlikely to me as well, because the lower bound does not make use of $\mu$ and the upper does not make use of $n$.

So, my first question is: Have the tightest bounds been described in the literature, and if so, where?

In case this question cannot be answered positively, I have a follow-up question: Are the bounds I derive below the tightest ones? (To start perhaps: Are they valid?)

In what follows, I assume without loss of generality (wlog) that $\mu=0$, so $m\leq0\leq M$. I will work with the samples through their order statistics, i.e.,

$$m=x_{(1)}\leq x_{(2)}\leq\dots\leq x_{(i)}\leq\dots\leq x_{(n-1)}\leq x_{(n)}=M.$$

So then

$$\mu=\frac{1}{n}\sum_{i=1}^nx_{(i)}=\frac{1}{n}\left(m+\sum_{i=2}^{n-1}x_{(i)}+M\right)=0$$

and

$$\sigma^2=\frac{1}{n-1}\sum_{i=1}^n{x_{(i)}}^2=\frac{1}{n-1}\left(m^2+\sum_{i=2}^{n-1}{x_{(i)}}^2+M^2\right).$$

Based on the principle that $kz^2\leq(kz)^2$ for $k\in\mathbb{Z}_{>0}$ and $z\in\mathbb{R}$, we construct hypothetical samples that should minimize and maximize the variance. First with as many possible values close to $\mu=0$ for the lower bound,

$$0=m+\sum_{i=2}^{n-1}x_{(i)}+M=m+(n-2)\nu+M,$$

where $\nu=-\frac{m+M}{n-2}$, so that

$$\sigma^2\geq\frac{1}{n-1}\left(m^2+(n-2)\nu^2+M^2\right).$$

Second with as many values far away from $\mu=0$ for the upper bound,

$$0=m+\sum_{i=2}^{n-1}x_{(i)}+M=n_mm+\kappa+n_MM,$$

where $n_m=\lfloor n\alpha\rfloor$ and $n_M=\lfloor n(1-\alpha)\rfloor$ with $\alpha=\frac{M}{M-m}$ from $0=\alpha m + (1-\alpha)M$ implying $(n_m+n_M=n\wedge\kappa=0)\vee(n_m+n_M=n-1\wedge m<\kappa<M)$, so that

$$\sigma^2\leq\frac{1}{n-1}\left(n_mm^2+\kappa^2+n_MM^2\right).$$

I have checked that these bounds are indeed tighter than the Nagy and Bathia-Davis ones. (I took wlog that $-m=1\geq M$ and plotted for $M\in(0,1]$ and $n\in[3,600]$.)

• I must be having problems reading today, because despite scanning this question many times I cannot find a definition of "$\kappa$" anywhere: exactly how is it determined by $M, m,n,$ and $\mu$ alone? BTW, the comments to the question at stats.stackexchange.com/questions/142655 might be of some interest concerning the upper bound.
– whuber
Commented Dec 7, 2017 at 16:31
• $\kappa$ is defined implicitly by the next-to-last displayed equation: $m\leq\kappa=-(n_mm+n_MM)\leq M$. Commented Dec 7, 2017 at 21:32
• @equaeghe The theorems you cited (Davies-Nagy) does not assume that $m=x_{(1)}$ nor $M=x_{(n)}$, they just say bounded variables. You are putting additional assumptions and claim a different result, so it is difficult to say what you mean by "tighter"? Commented Dec 12, 2022 at 6:54
• @Henry.L: m (minimum) and M (maximum) are bounds, so their results hold. That means that the extra assumption I'm making is that the minimum and maximum are known (that is explicit). So then given that, are my bounds tighter? Commented Dec 13, 2022 at 9:18
• Sure. I think so, but also more restrictive. Commented Dec 13, 2022 at 13:50

I was looking into the same question in the discrete case and just found your great question: I wanted to find the smallest possible sample standard deviation for a list of integers with known minimum, maximum, mean, and cardinality, and I found nothing beyond the citations you listed.

a) Your bounds on the variance look both correct and tight to me; you’ve described specific distributions that minimize and maximize the variance and have the same other given statistics.

b) It sure looks like the bounds you give are nowhere published. They deserve to be, I think. They’re certainly not published anywhere easy to find, and as it sounds like we’ve both seen, peer reviewers and editors sometimes aren’t aware of them! [Disclaimer: I’m not a statistician, and I haven’t done comprehensive research; I mostly googled, but I googled a lot, and that tends to work pretty well much of the time.]

In terms of a resource to help run “sanity checks” of summary statistics by testing whether a tuple $(n,m, M, \mu, \sigma)$ is mathematically possible (I think you left out $n$ near the top of your question), you could go a little further in a couple of ways.

• A bounds-check on $\sigma$ isn’t a definitive test for a tuple, because there is a minimum value of $n$ (depending on more-or-less how “centrally located” $\mu$ is with respect to $m$ and $M$) for which $n$ data values can have minimum $m$, maximum $M$, and mean $\mu$. If $n$ is too small, what you call $\nu$ will be outside the range $[m,M]$. For example, suppose $m=-1$, $M=10$, and $n=10$. Then $\nu=-\frac{m+M}{n-2}=-\frac98<m$.

• If the data are discrete, the bounds with that additional assumption are generally tighter, and exact bounds in that case would be good to give — at least for equally-spaced data, like “number of $X$” or Likert-scale survey data.

• Also, but maybe not worth the bother to work out, for the discrete case, not every possible $\sigma$ within your bounds is attainable for a given $n$, so the bounds-check isn’t definitive, even if $n$, $m$, $M$, and $\mu$ are simultaneously attainable.

For what it’s worth, I don’t immediately see the Nagy bound in the cited Nagy paper, either, but I’m not even close to fluent in mathematical German.

• We have several threads that establish the mathematical equivalent of $$\sigma^2 \le (\mu-m)(M-\mu)$$ for arbitrary distributions supported on $[M,m]$ and show that it is tight: the maximum is attained for a two-point distribution giving probability $(M-\mu)/(M-m)$ to $m$ and probability $(\mu-m)/(M-m)$ to $M.$ In light of this, the bounds given in the question look plausible (but I haven't checked the derivation). For your case the situation is more complicated, because $m,\mu,M$ alone determine a relatively small finite number of possible values of $\sigma^2.$
– whuber
Commented May 4, 2018 at 20:57
• “I think you left out n near the top of your question”: Thanks, clarified. Commented May 7, 2018 at 11:52
• “And more obviously, it must be the case that $m\leq\mu\leq M$”: I mention this as $m\leq0\leq M$ in my derivation, where $0=\mu$. Commented May 7, 2018 at 12:17
• “If n is too small, what you call $\nu$ will be outside the range $[m,M]$”: I don't think so; did you take into account that $\mu=0$ is assumed? Commented May 7, 2018 at 12:20
• “If the data are discrete, the bounds with that additional assumption are generally tighter”: I've now clarified that I consider the real-valued case. Also, I am quite sure that no general expression can be given in the discrete case, as you are faced with a non-linear integer programming problem to determine which sets of samples are feasible. (Of course, if you make additional assumptions, this picture may change.) Commented May 7, 2018 at 12:41