We can use our sample to construct a confidence interval within which we can be reasonably sure the actual population mean (or median) will lie. Even though every sample taken will vary, and every confidence interval will be different overall most (95%) or the confidence intervals will contain the true population mean (or median)
A larger sample results in a narrower confidence interval.
The greater the sample side the better our estimate of the population mean (or median)
A confidence interval does NOT correct for poor sampling methods, biased samples, or samples that do not represent the population well or contain errors. If the sample data is poor, the resulting confidence interval will be poor
To compare two populations to determine if the population means are different we construct a confidence interval for each population. If the confidence intervals overlap then we cannot say the population means are different. If the confidence intervals do not overlap then we can be reasonably sure that the population means are different.