I was reading an article that stated that if we know the mean $\bar{x}_{prev}$ of a dataset with $n$ datapoints, and that if we add a new data point $x_{k}$ to the dataset, then the new mean $\bar{x}_{new}$ can be expressed by the formula:
$\bar{x}_{new} = \bar{x}_{prev} + \frac{1}{n+1}(x_k-\bar{x}_{prev})$
It is not obvious to me how this expression is true.
This is my attempt at deriving the expression:
$\bar{x}_{new}=\frac{1}{n+1}\sum_{i=1}^{n+1}{x_i} = \frac{1}{n+1}(x_{k} + \sum_{i=1}^{n}x_i)$
Note that $\sum_{i=1}^{n}x_i = n\bar{x}_{prev}$
$\bar{x}_{new}=\frac{1}{n+1}(x_{k} + n\bar{x}_{prev})$
but is does not seem like this is getting me anywhere.
$$\bar{x}_{new}=\frac{1}{n+1}(x_{k} + n\bar{x}_{prev})=\bar{x}_{prev}+\frac{1}{n+1}(x_{k} + n\bar{x}_{prev}-(n+1)\bar{x}_{prev})$$ $$\bar{x}_{new}=\bar{x}_{prev} + \frac{1}{n+1}(x_k-\bar{x}_{prev})$$