[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet-scheme] 02/04: nse/client: Allow NaN as standard deviation.
From: |
gnunet |
Subject: |
[gnunet-scheme] 02/04: nse/client: Allow NaN as standard deviation. |
Date: |
Wed, 22 Sep 2021 20:56:52 +0200 |
This is an automated email from the git hooks/post-receive script.
maxime-devos pushed a commit to branch master
in repository gnunet-scheme.
commit 97dcd0b885881ed86ef726d1604873fde6f2affa
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Wed Sep 22 20:29:21 2021 +0200
nse/client: Allow NaN as standard deviation.
See <https://bugs.gnunet.org/view.php?id=7021#c18399>.
* doc/scheme-gnunet.tm
(Estimation of the size of the network)[estimate:standard-deviation]:
Document it.
---
doc/scheme-gnunet.tm | 13 +++++++++----
gnu/gnunet/nse/client.scm | 11 ++++++++---
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/doc/scheme-gnunet.tm b/doc/scheme-gnunet.tm
index 83e0a0b..e504622 100644
--- a/doc/scheme-gnunet.tm
+++ b/doc/scheme-gnunet.tm
@@ -1047,10 +1047,15 @@
<\explain>
<scm|(estimate:standard-deviation <var|estimate>)>
- </explain|The estimated standard deviation on the base-2 logarithm of
- peers, calculated over the last 64 rounds, with the <math|<frac|N|N-1>>
- correction.<space|1em>This is a positive flonum, possibly zero or
- infinite.>
+ <|explain>
+ The estimated standard deviation on the base-2 logarithm of peers,
+ calculated over the last 64 rounds, with the <math|<frac|N|N-1>>
+ correction.<space|1em>This is a positive flonum, possibly zero or
+ infinite, or not-a-number (indicating division of zero by zero).
+
+ If the peer has been connected to the network for a while, the number is
+ expected to be finite and strictly positive.
+ </explain>
Assuming the network size is stable and the errors on the logarithmic
estimate are normally distributed, the procedure
diff --git a/gnu/gnunet/nse/client.scm b/gnu/gnunet/nse/client.scm
index 7b0c6dd..d240c28 100644
--- a/gnu/gnunet/nse/client.scm
+++ b/gnu/gnunet/nse/client.scm
@@ -36,7 +36,7 @@
estimate)
(import (only (rnrs base)
begin define quote lambda case values expt = else apply
- and >=)
+ and >= let or nan?)
(only (rnrs control)
when unless)
(only (rnrs records syntactic)
@@ -104,7 +104,7 @@ in @var{estimate} as a positive flonum (possibly zero or
infinite)."
(define (estimate:standard-deviation estimate)
"Return the standard deviation of the logarithmic estimate
of the number of peers of the last 64 rounds as a positive flonum
-(possibly zero or infinite)."
+(possibly zero or infinite), or not-a-number."
(%estimate:standard-deviation estimate))
(define (estimate:number-peers estimate)
@@ -147,7 +147,12 @@ even if not connected. This is an idempotent operation."
(sizeof /:msg:nse:estimate '()))
;; XXX: these two lines below are not tested
(>= (read% /:msg:nse:estimate '(size-estimate) slice) 0)
- (>= (read% /:msg:nse:estimate '(std-deviation) slice) 0)))
+ ;; See <https://bugs.gnunet.org/view.php?id=7021#c18399> for
+ ;; situations in which the deviation can be infinite or NaN.
+ (let ((stddev
+ (read% /:msg:nse:estimate '(std-deviation) slice)))
+ (or (>= stddev 0)
+ (nan? stddev)))))
((handle! slice) (handle-estimate! slice)))))
(define (send-start!)
;; The service only starts sending estimates once
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.