Skip to content

Commit 29b9797

Browse files
committed
Fix missing sqrt in root dispersion calculation.
1 parent 2dc2204 commit 29b9797

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ntp-proto/src/system.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ pub struct TimeSnapshot {
4343
impl TimeSnapshot {
4444
pub fn root_dispersion(&self, now: NtpTimestamp) -> NtpDuration {
4545
let t = (now - self.root_variance_base_time).to_seconds();
46+
// Note: dispersion is the standard deviation, so we need a sqrt here.
4647
NtpDuration::from_seconds(
47-
self.root_variance_base
48+
(self.root_variance_base
4849
+ t * self.root_variance_linear
4950
+ t.powi(2) * self.root_variance_quadratic
50-
+ t.powi(3) * self.root_variance_cubic,
51+
+ t.powi(3) * self.root_variance_cubic)
52+
.sqrt(),
5153
)
5254
}
5355
}

0 commit comments

Comments
 (0)