ESPresense / ESPresense-companion

HA Add-on / Docker container that solves indoor positions with mqtt data received from multiple ESPresense stations
Apache License 2.0
118 stars 9 forks source link

Gaussian Weighting Function Math? #567

Open dxmnkd316 opened 4 months ago

dxmnkd316 commented 4 months ago

Is the Gaussian function written correctly? Maybe I missed something but it looks like it's missing a power in the first sigma term? var y = 1d / Math.Sqrt(_sigma 2d Math.PI) Math.Exp(-(Math.Pow(x, 2d) / (2d Math.Pow(_sigma, 2d))))

should this be:

var y = 1d / Math.Sqrt(Math.Pow(_sigma, 2d) 2d Math.PI) Math.Exp(-(Math.Pow(x, 2d) / (2d Math.Pow(_sigma, 2d))))

DTTerastar commented 4 months ago

According to chat gpt we're both wrong:

https://chat.openai.com/share/32ab4ad6-181a-4974-9868-a5a9abfa5b1e

DTTerastar commented 4 months ago

0.65 has the fix. Doesn't seem too different to me, but lmk.

dxmnkd316 commented 2 months ago

Just wanted to circle back on this. I recently added a bunch of new base stations around the house. I've been playing with the gaussian weighting a bit more and I'm finding a couple things:

  1. More base stations doesn't necessarily mean better accuracy. Which is weird! I suspect this is because of my choice of placement and orientation, which I'm going to play around with. I also suspect I should probably standardize on a single model of base station. I've got a couple of WROOMs that are nowhere near as sensitive as the Atom Lite S3s I have.
  2. I'm finding the Gaussian sigma needs to be significantly higher than 0.3 for stable readings. Anything less than 0.5-0.67 and the rooms jump. Which makes a lot of sense given how I assume the weighting works. The closer to 1, the closer it becomes an average of readings, right? Once I bumped the sigma to 0.67, I found the readings to be very stable. Every change in signal had a smaller weight and it would only pick up larger movements in position. I find this preferable, I just need to get the calibration down.

Edit: May have spoken too soon. I had to drop the sigma back down. It just started pushing my devices outside of the house. I probably need to also dial back the max distances.