# How to calculate a 95% confidence interval from time data?

I have a few (e.g. 10) observations of travel times for a route.

A commuter needs to arrive to his destination before t0 (given).

I want to say: The commuter should depart before t0 - x to arrive to his destination at t0 with probability 95%.

Can I do this just by calculating the sample mean (m) and standard deviation (s) and say that

x = m + 2*s


(the 2 is an approximation of the 2 sigma)

? Thanks.

-

## 3 Answers

What you've posted is how to get the 95% confidence interval for a normally distributed mean. You can certainly use it for your times, assuming that the normal distribution well describes the distribution of your arrival times (assuming normality for time variables usually makes me a bit skittish). Though you should use 1.96 as the approximation, as you'll likely not be calculating this by hand anyway.

However you're calculating a two sided confidence interval. If you use the upper limit, only 2.5% of repeated samples of a commuter leaving to his destination will be over that upper limit, not the 5% you're looking for.

What you actually want is a 90% confidence interval, which will use 1.645 instead of 1.96 as the multiplier. That will give you 5% of the distribution on each side of the limit.

-

Assuming that the travel time is close enough to normally-distributed, you are on the right track. However, there are two issues that you have not got quite right.

First, your description makes it sound like a one-tailed interval is what you need (95% probability of arriving before the cutoff time). Your calculation is an approximation of a 95% two-tailed interval.

Second, your calculation x = m * 2s for a confidence interval of the mean assumes that the standard deviation is known (i.e. s = sigma) or is accurate (i.e. the number of observations is large enough that s can be assumed to be very close to sigma). In reality there is almost never a good reason to use that approach instead of the one that correctly assumes that s is an observed estimate of sigma. Therefore, use the calculation of t * s instead of 2 * s, where t is the value from Student's t-distribution relevant to the experiment. For your experiment use a one-tailed t value (0.05 area in the tail) for 9 degrees of freedom, 1.83.

Thus you need to start traveling at time t0 - 1.83 * s to have a 95% probability of arriving before time t0.

-

Your question and previous answers are fine IF the travel times are Gaussian.
But what if they're not ? Take samples of size 9 for simplicity. The average min-of-9 will be the 10 th percentile, i.e. 10 % of the trips will be shorter than that; similarly, 10 % will be longer than the average max-of-9. (Hope that's intuitive: first for a uniform distribution, then for any.) But the mins-of-9 / maxes-of-9 may scatter a lot.

To see how close your times are to Gaussian, make a Q-Q plot.

(I'd like to see a robust or Bayesian statistician's answer. Choose a Gaussian prior, run 9-samples of say a Laplace distribution, see how the posterior distributions change ?)

-