0
$\begingroup$

Let's say I have an array of values drawn from a normal distribution with mean 50 and standard deviation 10. Using python:

d = np.random.normal(50,10,1000)

I take a single random sample of size n = 10 from this distribution:

s = np.random.choice(d, 10)

What process do I go through to get the best estimate of the population mean from the sample, and an estimation of the margin of error?

Obviously I know the population mean and standard deviation in this case, but let's pretend I don't.

I could also take many samples and compute the sampling distribution of the mean, but let's say I can't do that either.

So I just have this single sample. What process do I go through and can I estimate how often my estimate of the population mean will be wrong?

$\endgroup$
  • 1
    $\begingroup$ The sample mean is the best thing you could do. $\endgroup$ – Aksakal Dec 23 '16 at 19:04
  • $\begingroup$ Yes, but I want an estimate of how accurate this is. How often will it be wrong, and by how much? $\endgroup$ – user1654183 Dec 23 '16 at 19:32
  • 1
    $\begingroup$ then your question title is misleading. the variance of the sample mean will answer these questions, whether you do it based on normal distribution or by bootstrapping $\endgroup$ – Aksakal Dec 23 '16 at 19:34
  • $\begingroup$ To slightly improve on @Aksakal's answer. The sample mean in this situation is the best estimator of the population mean (mean of the underlying unknown distribution) if you are interested in unbiased estimators. Where best is defined as having the smallest variance. A margin of error can be calculated using the standard sample variance. With respect to how often your estimate will be wrong, the probability that your sample mean will be equal to the population mean is zero for a normally dist sample. This is a property of the population mean being a parameter on a continuous interval. $\endgroup$ – Jonathan Lisic Dec 23 '16 at 19:34
  • $\begingroup$ I agree with most of the comments. The issue that disturbs me is saying "How often is the estimate wrong?" I guess that means it is wrong whenever it is not equal to 10. In theory the normal estimate using the sample mean will never be exactly 10. Aksakal and Jonathan Lisic are giving you very sensible answers. $\endgroup$ – Michael Chernick Dec 23 '16 at 20:10
2
$\begingroup$

I'm assuming infinite population size.

The best estimate of the population mean is the sample mean, $\bar{x}$.

The best estimate of the population standard deviation is the sample standard deviation, $s = \sqrt{\frac{1}{n-1} \sum_{i=1}^n (x_i - \overline{x})^2}$

Since the sample size is less than 30 (10 in this case) and the population standard deviation is unknown, I would prefer to use the T-distribution to develop an interval.

$\bar{x} \pm t(\frac{s}{\sqrt{n}})$

where $t$ is the critical value from the $t_{n-1}$ distribution. In your case with n=10 and a desired confidence level of 95%, $t_{9}=1.833$.

More details can be found in this Example.

$\endgroup$
2
$\begingroup$

Though Underminer gives a perfectly good answer, I thought I would take the time to provide a Bayesian estimate.

In your problem, you don't explicitly say you have no reason to believe the data are normal, only that the mean and the variance are unknown. The likelihood function is thus

$$ y \sim \mathcal{N}(\mu, \sigma^2)$$

Here, $\mu, \sigma$ must be estimated. I'll place an uninformative prior on both of these parameters

$$ p(\mu, \sigma^2) \propto (\sigma^2)^{-1} \>.$$

In Bayesian Data Analysis 3 (p.g. 64) Gelman goes through this example and derives an analytic posterior density. The marginal posterior for the variance is

$$\sigma^{2} | y \sim \operatorname{Inv}-\chi^{2}\left(n-1, s^{2}\right)$$

with

$$ s^{2}=\frac{1}{n-1} \sum_{i=1}^{n}\left(y_{i}-\overline{y}\right)^{2}$$

while the marginal posterior for the mean conditioned on the variance and the data is

$$\mu | \sigma^{2}, y \sim \mathrm{N}\left(\overline{y}, \sigma^{2} / n\right)$$

We can sample from these densities very easily with python and compute credible intervals.

from scipy.stats import norm, chi2

import numpy as np
import matplotlib.pyplot as plt


population = norm(loc = 50, scale = 10)

n = 10
samp = population.rvs(n)

ybar = samp.mean()
s = samp.var(ddof = 1)

var_posterior = (n-1)*s/chi2(df =n-1).rvs(100_000)
mu_posterior = norm(loc = ybar, scale = np.sqrt(var_postrior/n)).rvs()


#Now for credible intevals
print(np.percentile(mu_posterior, [2.5, 97.5]))
print(np.percentile(np.sqrt(var_posterior), [2.5, 97.5]))

fig, ax = plt.subplots()
ax.hist(mu_posterior, bins = 25)

fig,ax = plt.subplots()
ax.hist(np.sqrt(var_posterior), bins = 25)
plt.show()

The benefit from this method is that you get uncertainty estimates of the variance for cheap, whereas Underminer's method only gives you uncertainty estimates for the mean.

It actually turns out that the posterior is the student-t density (go figure), so all this is more or less equivalent to Underminer's approach. However, that is only because we assumed we knew nothing about the mean and the variance before hand. If we knew something about those parameters (for instance, that negative values are impossible, or that they were larger than some number) then we could do much more by means of MCMC.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.