r. j. gordon

Decoding Linear Prediction

Written by on

Last blog post I talked about the method I would be using to detect elevated levels of stress/fear in a user based on their mouse movements. Essentially what I proposed to do was follow a method used by researchers at UC Berkeley. By treating mouse movements as the signal output of a Mass Spring Damper system, I planned to use Linear Predictive Coding to retrieve the input parameters of that system. However, I didn't really talk about what was happening under the hood. LPCThe reason a mass spring damper system is useful to me is that it can be used to describe a system of a human's arm and wrist movements. The damping variables basically are indicators of muscle tension. Henceforth what I needed to do was to retrieve the inputs of the system (the parameters of an MSD's characteristic polynomial) from the systems output (the mouse movement, which is treated as a signal).

This is where Linear Prediction comes in. In audio processing, Linear Prediction is used to strip away noise from a signal to find it's true values, and predict future values of the signal based on it's previous ones. This is helpful because if applied to the mouse signal, it strips away the noise of the mouse movements and leaves what it perceives to be 'the true' signal. This is useful because while it removes the typical randomness from the mouse movements and leaves behind a series of coefficients that describe the characteristics of the signal. These are the same coefficients that describe the input parameters of the MSD. From there, I can just look at the coefficients that describe the damping ratio and frequency, and use those to derive elevated muscle tension (higher values mean higher muscle tension, and lower values imply the opposite). Because this same method was used to predict elevated heart beat from elevated muscle tension, in my context I can interpret this as elevated fear and stress. LPC in audio The algorithm behind Linear Prediction is a bit complicated. Essentially it attempts to solve an equality in the form of a matrix, using the Levinson-Durbin algorithm to achieve this. The Levinson-Durbin algorithm is a bit complicated and honestly I have only a superficial understanding of how it works, but I was able to successfully implement it in Python. There's a paper that goes in depth in how it works here.

Ultimately I have been able to implement in Python, and I am retrieving the coefficients as expected. Next step is the actual genetic algorithm, but that's another post.

Through much expirementation, mathematics, and some head-banging, I was able to develop a formula to correctly correlate voltage to RPM.

The resulting program, I called GPSS- GPSS is a Precise Scribbling System. Using GPSS, a user can specify the exact degree they want the Scribbler turn to, or the exact distance they want the Scribbler to move to, and the Scribbler will consitantly reproduce the same results regardless of battery voltage. (Almost).

Tags: high school, linear prediction, audio processing, levinson-durbon, mousesp, emotional state prediction, mass spring damper