# Iterative Power Regression

If I have a set of data points that would fit inside a power equation of the form y = a*x^b, what is the best ITERATIVE method to find the values of 'a' and 'b'.

I thought I could compute the error in each assumption of 'a' and 'b', but how would I vary each?

First you make the usual transformations $y \rightarrow \ln y$ and $x \rightarrow \ln x$. With these new variables you do the step-wise iterative update of the usual sums for $n=1,2,\dots$ (the sums are initialized to zero) \begin{aligned} M_x^{(n)} &= M_x^{(n-1)} + \frac{x_n-M_x^{(n-1)}}{n}\\ M_y^{(n)} &= M_y^{(n-1)} + \frac{y_n-M_y^{(n-1)}}{n}\\ S_x^{(n)} &= S_y^{(n-1)} + \frac{(n-1)\left(x_n-M_x^{(n-1)}\right)^2}{n}\\ S_y^{(n)} &= S_y^{(n-1)} + \frac{(n-1)\left(y_n-M_y^{(n-1)}\right)^2}{n}\\ C_{xy}^{(n)} &= C_{xy}^{(n-1)} + \frac{(n-1)(x_n-M_x^{(n-1)}) (y_n-M_y^{(n-1)})}{n} \end{aligned} After each iterative step you can compute your values as $$b^{(n)} = \frac{C_{xy}^{(n)}}{S_x^{(n)}}$$ and $$\ln a^{(n)} = M_y^{(n)} - b^{(n)} M_x^{(n)}.$$