Obviously you will need to know the type of confidence interval you are dealing with, but let's suppose that this is a standard one-sample confidence interval for the mean, using the standard T-statistic as the pivotal quantity. In that case, the formula for the interval is:
$$\text{CI}(1-\alpha) = \Bigg[ \bar{x} \pm \frac{t_{n-1, \alpha/2}}{\sqrt{n}} \cdot s \Bigg].$$
Thus, if we denote the known lower and upper bounds of the interval as $l$ and $u$ respectively, then you can algebraically reverse-engineer the sample mean and sample standard deviation as:
$$\bar{x} = \frac{l+u}{2}
\quad \quad \quad \quad \quad
s = \frac{u-l}{2} \cdot \frac{\sqrt{n}}{t_{n-1, \alpha/2}}.$$
With the values specified in your example, you get:
#Set preliminary values
l <- 5.18;
u <- 5.38;
n <- 300;
alpha <- 0.05;
#Compute sample mean and SD
crit <- qt(alpha/2, df = n-1, lower.tail = FALSE);
MEAN <- (l+u)/2;
SD <- (u-l)*sqrt(n)/(2*crit);
#Print the values
MEAN;
[1] 5.28
SD;
[1] 0.8801386
Thus, assuming that your interval was a standard one-sample confidence interval, you must have had a sample mean $\bar{x} = 5.28$ and sample standard deviation $s = 0.88$.
The sample standard deviation is given by
$$\begin{align*}
s
&=\sqrt{\frac{\sum\left(x_i-\bar{x}\right)^2}{n-1}}\\\\
&=\sqrt{\frac{\sum\left(x_i^2-2x_i\bar{x}+\bar{x}^2\right)}{n-1}}\\\\
&=\sqrt{\frac{n\bar{x}^2+\sum x_i^2-2\bar{x}\sum x_i}{n-1}}\\\\
&=\sqrt{\frac{n\bar{x}^2+\sum x_i^2-2n\bar{x}^2}{n-1}}\\\\
&=\sqrt{\frac{\sum x_i^2-n\bar{x}^2}{n-1}}\\\\
\end{align*}$$
so having $\bar{x}, n,\text{ and}\sum x_i^2$ suffices for calculating the sample standard deviation.
Best Answer
If you know there are two values, then you can figure out what they are.
$$ \bar x = \dfrac{1}{n}\sum_{i=1}^nx_i = \dfrac{1}{2}\big(x_1 + x_2\big)\\ s^2 = \dfrac{1}{n-1}\sum_{i = 1}^n\big(x_i - \bar x\big)^2 = (x_1 - \bar x)^2 + (x_2 - \bar x)^2 $$
Solve the system of equations. Wolfram Alpha gives two solutions, but the way of interpreting them is that the calculation does not know which value is $x_1$ (
x
) and which value is $x_2$ (y
), and it is true that you do not know which value is which.$$ x_1 = \dfrac{1}{2}\bigg( 2\bar x - \sqrt{2s^2} \bigg)\\ x_2 = \dfrac{1}{2}\bigg( 2\bar x + \sqrt{2s^2} \bigg)\\ $$
Let's do a quick check in software.
This should reveal why it is problematic to figure out the original values from just the mean, standard deviation, and sample size, however. You wind up with two equations but more then two unknowns, so there are multiple solutions.
If you have two points where $\bar x = 5.6$ and $s = 0.13$, then you can apply my code to solve that the points are $5.50807611844575$ and $5.69192388155425$.