←back to thread

146 points hugohadfield | 3 comments | | HN request time: 0s | source

This little project came about because I kept running into the same problem: cleanly differentiating sensor data before doing analysis. There are a ton of ways to solve this problem, I've always personally been a fan of using kalman filters for the job as its easy to get the double whammy of resampling/upsampling to a fixed consistent rate and also smoothing/outlier rejection. I wrote a little numpy only bayesian filtering/smoothing library recently (https://github.com/hugohadfield/bayesfilter/) so this felt like a fun and very useful first thing to try it out on! If people find kalmangrad useful I would be more than happy to add a few more features etc. and I would be very grateful if people sent in any bugs they spot.. Thanks!
Show context
pm ◴[] No.41864206[source]
Congratulations! Pardon my ignorance, as my understanding of mathematics at this level is beyond rusty, but what are the applications of this kind of functionality?
replies(5): >>41864688 #>>41864699 #>>41864774 #>>41865843 #>>41872941 #
caseyy ◴[] No.41865843[source]
This is very important in controllers using feedback loops. The output of a controller is measured, a function is applied to it, and the result is fed back into the controller. The output becomes self-balancing.

The applications in this case involve self-driving cars, rocketry, homeostatic medical devices like insulin pumps, cruise control, HVAC controllers, life support systems, satellites, and other scenarios.

This is mainly due to a type of controller called the PID controller which involves a feedback loop and is self-balancing. The purpose of a PID controller is to induce a target value of a measurement in a system by adjusting the system’s inputs, at least some of which are outputs of the said controller. Particularly, the derivative term of a PID controller involves a first order derivative. The smoother its values are over time, the better such a controller performs. A problem where derivative values are not smooth or second degree derivative is not continuous, is called a “derivative kick”.

The people building these controllers have long sought after algorithms that produce at least a good approximation of a measurement from a noisy sensor. A good approximation of derivatives is the next level, a bit harder, and overall good approximations of the derivative are a relatively recent development.

There is a lot of business here. For example, Abbott Laboratories and Dexcom are building continuous blood glucose monitors that use a small transdermal sensor to sense someone’s blood glucose. This is tremendously important for management of people’s diabetes. And yet algorithms like what GP presents are some of the biggest hurdles. The sensors are small and ridiculously susceptible to noise. Yet it is safety-critical that the data they produce is reliable and up to date (can’t use historical smoothing) because devices like insulin pumps can consume it at real time. I won’t go into this in further detail, but incorrect data can and has killed patients. So a good algorithm for cleaning up this noisy sensor data is both a serious matter and challenging.

The same can be said about self-driving cars - real-time data from noisy sensors must be fed into various systems, some using PID controllers. These systems are often safety-critical and can kill people in a garbage in-garbage out scenario.

There are about a million applications to this algorithm. It is likely an improvement on at least some previous implementations in the aforementioned fields. Of course, these algorithms also often don’t handle certain edge cases well. It’s an ongoing area of research.

In short — take any important and technically advanced sensor-controller system. There’s a good chance it benefits from advancements like what GP posted.

P.S. it’s more solved with uniformly sampled data (i.e. every N seconds) than non-uniformly sampled data (i.e. as available). So once again, what GP posted is really useful.

I think they could get a job at pretty big medical and automotive industry companies with this, it is “the sauce”. If they weren’t already working for a research group of a self-driving car company, that is ;)

replies(1): >>41868993 #
082349872349872 ◴[] No.41868993[source]
Thinking about people as PID controllers: left to our own devices we're normally very good at the D term, but lousy at the I term, with the P term somewhere in the middle.

Give people clay/parchment/paper, however, and it becomes much easier to reliably evaluate an I term.

Example: https://xkcd.com/1205/ ; maybe each single time you do the task it seems like sanding out the glitches would be more trouble than it's worth, but a little record keeping allows one to see when a slight itch becomes frequent enough to be worth addressing. (conversely, it may be tempting to automate everything, but a little record keeping allows one to see if it'd obviously be rabbit holing)

replies(1): >>41871192 #
caseyy ◴[] No.41871192[source]
You might like the second episode of All Watched Over by Machines of Loving Grace. It talks about how techno-utopians tried to model society and nature as feedback loop controllers.

One might say a part of the reason they have failed is because nature and people don't much care for the I term. These systems have feedback loops for sudden events, but increase the temperature slowly enough and the proverbial frog boils.

There are very many undercurrents in our world we do not see. So much that even when we think we understand and can predict their effects, we almost never take into account the entire system.

replies(1): >>41874835 #
1. 082349872349872 ◴[] No.41874835[source]
Thanks! Parts of that ep reminded me greatly of The Tyranny of Structurelessness (1971-1973): https://www.jofreeman.com/joreen/tyranny.htm

(the notion that we tend to overly ascribe stability and reproducibility to a system reminds me of Vilfredo Pareto having convinced himself that 80-20 was the invariable power law)

replies(1): >>41875560 #
2. caseyy ◴[] No.41875560[source]
That was a very interesting read, thanks. Structurelessness seems to be very fertile ground for structure and organization.
replies(1): >>41877471 #
3. 082349872349872 ◴[] No.41877471[source]
Rotating people through the root ("central" if you insist on camouflaging the hierarchy*) positions seems an excellent idea. The biggest problem with rotations in general is the existence of domains requiring large amounts of specific knowledge, but I don't think anyone is arguing that administrative positions are among them.

— We're taking turns to act as a sort of executive officer for the week

— Yes...

— But all the decisions of that officer have to be ratified at a special bi-weekly meeting

— Yes I see!

— By a simple majority, in the case of purely internal affairs

Be quiet!

— But by a two-thirds majority, in the case of more major

Be quiet! I order you to be quiet!

(I wonder how the Pythons themselves handled group decisions?)

* but see expander networks for a possible alternative network structure