## Vertical speed estimation by least squares methodThis method finds the line \(y = ax + b\) that has minimal sum of squared residuals (RSS) in a given set of \( n \) pairs \( (x_i, y_i) \): \[ \begin{equation} (x_1, y_1), (x_2, y_2), ... (x_{n}, y_{n}) \end{equation} \]In this case, \(x\) is time and \(y\) is altitude. Residual at each point is the vertical distance from the line: \[ \begin{equation} \hat\epsilon_i = y_i - (ax_i + b) \end{equation} \]Sum of squared residuals: \[ \begin{equation} \sum_{i=1}^n \hat\epsilon_i^2 = \sum_{i=1}^n (y_i^2 - 2ax_{i}y_{i} - 2by_{i} + a^{2}x_i^2 + 2abx_{i} + b^2) \end{equation} \]For the given set of \( (x, y) \) pairs, RSS can be defined as a function of the line parameters \( g(a, b) \), with all \( x_i \) and \( y_i \) held constant. At the minimum point, partial derivatives will be zero. \[ \begin{equation} \frac{\partial g}{\partial a} = \sum_{i=1}^n (2ax_i^2 + 2bx_{i} - 2x_{i}y_{i}) = 0 \end{equation} \] \[ \begin{equation} \frac{\partial g}{\partial b} = \sum_{i=1}^n (2ax_{i} + 2b - 2y_i) = 0 \end{equation} \]Line parameters can be found by solving the above set of two equations. \[ \begin{equation} a = \frac{n \sum_{i=1}^n x_{i}y_{i} - \sum_{i=1}^n x_i \sum_{i=1}^n y_i}{n \sum_{i=1}^n x_i^2 - (\sum_{i=1}^n x_i)^2} \end{equation} \] \[ \begin{equation} b = \frac{\sum_{i=1}^n y_{i} - \sum_{i=1}^n ax_i}{n} \end{equation} \]If \( x \) is time and \( y \) is altitude, \( a \) is the estimated vertical speed and \( b \) is the altitude at zero time.
A plot of pressure measured by Galaxy Nexus pressure sensor (BOSCH BMP180) in an elevator of one of the Manhattan skyscrapers.
Pressure altitude computed by Android - Sample data used for this plot
- Linear regression implementation in Python
- ML version (gradient descent) with TensorFlow
The Vertical Speed Indcator application uses this method to estimate climb/descent rate. Adding vertical accelerometer and using Kalman filter to process the data may improve speed estimation, but this approach requires keeping track of sensor orientation. ©Ivan Gorinov, 2013 |