Fix mean() calculation on first 31 samples#800
Fix mean() calculation on first 31 samples#800pftbest wants to merge 1 commit intopendulum-project:mainfrom
Conversation
Signed-off-by: Vadzim Dambrouski <pftbest@gmail.com>
|
Hmmm, there might be an actual problem here, I would have to dive into this in detail to figure this out for sure. If it is, this is definitely not the only place. Since we are planning to work on a general overhaul of the algorithm soon anyways, I prefer not to spend time on it now, and postpone it to just the general overhaul. Are you seeing any actual problematic behavior at startup? |
|
@davidv1992 I am working on a project where I need to discipline the PHC using 1pps input only without PTP. I was rewriting this part of the code to use delta between two consecutive measurements instead of Delay pair (because we don't have delay measurement for 1pps input). And because input measurements come in only once per second the 32 buffer fills much slower, so I noticed the difference. I suspect in typical PTP network measurements come in multiple times per second so the buffer fills much quicker and it would be much harder to notice any effect of this. After the buffer is filled the calculation is correct, so this only affects startup. |
|
Okay, I think I am going to postpone fixing this until the algorithm overhaul. Therefore I will close this for now. |
|
You were right, variance() is also dividing by the buffer size, I missed it too |
The mean() is calculated incorrectly for the first 31 samples as the value is divided by the buffer size, not the number of samples. This can cause incorrect variance() estimation at the start when buffer is not fully filled.