## Rate of Inflation of Gas

Model: $p(t) = p_0(1+r)^t$ where $r$ is the rate of inflation. This can also be written as: $p(t) = p_0e^{\gamma t}$
Given series of data points $(p_i,t_i)$ construct cost fn. $e = \sum_i (p_i - p_0e^{\gamma t_i})^2$
Need to find $p_0$ and $\gamma$ that minimize $e$. $\frac{de}{dp_0} = \sum_i 2(p_i - p_0e^{\gamma t_i})(-e^{\gamma t_i}) = 0$ $\frac{de}{d\gamma} = \sum_i 2(p_i - p_0e^{\gamma t_i})(-p_0t_ie^{\gamma t_i}) = 0$
Simplify above two equations to $\sum_i \alpha_i \beta_i = 0$ ….(1)
and $\sum_i \alpha_i \beta_i t_i = 0$ ….(2)
where $\alpha_i = p_i - p_0 \beta_i$ $\beta_i = e^{\gamma t_i}$
Simplify (1) to give $p_0 = \frac{\sum_i p_i \beta_i}{\sum_i \beta_i^2}$ ….(3)
substitute value of $p_0$ from (3) into (2) to give $f(\gamma) = \sum_i (p_i - p_0(\gamma)\beta_i(\gamma))\beta_i(\gamma) t_i = 0$
Now use Newton’s method to find roots of $f(\gamma)$ $\gamma_{n+1} = \gamma_n - \frac{f(\gamma_n)}{f^{'}(\gamma_n)}$
After lots of algebra, verify $f^{'}(\gamma) = -2p_0 \beta_i^2 t_i^2 - p_0^{'} \beta_i^2 t_i + p_i \beta_i t_i^2$ $p_0^{'}(\gamma) = \frac{bc-ad}{c^2}$
where $a = 2\sum_i \beta_i p_i$ $b = \sum_i p_i \beta_i t_i$ $c = \sum_i \beta_i^2$ $d = \sum_i \beta_i^2 t_i$

Output of program (Newton’s method): $\gamma$ = 0.0584642367944379, residual = 8264.22684488131 $\gamma$ = 0.0394587424266077, residual = 755.065800336963 $\gamma$ = 0.0373150889455502, residual = 11.93657393052 $\gamma$ = 0.0372800836836129, residual = 0.00330268916627574
Rate of inflation: 3.798%
Residual = 0.00330268916627574
Iterations = 4

http://db.tt/PeU0ZBmK

This entry was posted in Money. Bookmark the permalink.