aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Devos <maximedevos@telenet.be>2021-09-22 20:29:21 +0200
committerMaxime Devos <maximedevos@telenet.be>2021-09-22 20:29:21 +0200
commit97dcd0b885881ed86ef726d1604873fde6f2affa (patch)
treeb0635c3bdd488dc483bd7e810d103038da50b162
parent749ced44b5baf6555dee1cd0c0f977b91670a547 (diff)
downloadgnunet-scheme-97dcd0b885881ed86ef726d1604873fde6f2affa.tar.gz
gnunet-scheme-97dcd0b885881ed86ef726d1604873fde6f2affa.zip
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.
-rw-r--r--doc/scheme-gnunet.tm13
-rw-r--r--gnu/gnunet/nse/client.scm11
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 @@
1047 1047
1048 <\explain> 1048 <\explain>
1049 <scm|(estimate:standard-deviation <var|estimate>)> 1049 <scm|(estimate:standard-deviation <var|estimate>)>
1050 </explain|The estimated standard deviation on the base-2 logarithm of 1050 <|explain>
1051 peers, calculated over the last 64 rounds, with the <math|<frac|N|N-1>> 1051 The estimated standard deviation on the base-2 logarithm of peers,
1052 correction.<space|1em>This is a positive flonum, possibly zero or 1052 calculated over the last 64 rounds, with the <math|<frac|N|N-1>>
1053 infinite.> 1053 correction.<space|1em>This is a positive flonum, possibly zero or
1054 infinite, or not-a-number (indicating division of zero by zero).
1055
1056 If the peer has been connected to the network for a while, the number is
1057 expected to be finite and strictly positive.
1058 </explain>
1054 1059
1055 Assuming the network size is stable and the errors on the logarithmic 1060 Assuming the network size is stable and the errors on the logarithmic
1056 estimate are normally distributed, the procedure 1061 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 @@
36 estimate) 36 estimate)
37 (import (only (rnrs base) 37 (import (only (rnrs base)
38 begin define quote lambda case values expt = else apply 38 begin define quote lambda case values expt = else apply
39 and >=) 39 and >= let or nan?)
40 (only (rnrs control) 40 (only (rnrs control)
41 when unless) 41 when unless)
42 (only (rnrs records syntactic) 42 (only (rnrs records syntactic)
@@ -104,7 +104,7 @@ in @var{estimate} as a positive flonum (possibly zero or infinite)."
104 (define (estimate:standard-deviation estimate) 104 (define (estimate:standard-deviation estimate)
105 "Return the standard deviation of the logarithmic estimate 105 "Return the standard deviation of the logarithmic estimate
106of the number of peers of the last 64 rounds as a positive flonum 106of the number of peers of the last 64 rounds as a positive flonum
107(possibly zero or infinite)." 107(possibly zero or infinite), or not-a-number."
108 (%estimate:standard-deviation estimate)) 108 (%estimate:standard-deviation estimate))
109 109
110 (define (estimate:number-peers estimate) 110 (define (estimate:number-peers estimate)
@@ -147,7 +147,12 @@ even if not connected. This is an idempotent operation."
147 (sizeof /:msg:nse:estimate '())) 147 (sizeof /:msg:nse:estimate '()))
148 ;; XXX: these two lines below are not tested 148 ;; XXX: these two lines below are not tested
149 (>= (read% /:msg:nse:estimate '(size-estimate) slice) 0) 149 (>= (read% /:msg:nse:estimate '(size-estimate) slice) 0)
150 (>= (read% /:msg:nse:estimate '(std-deviation) slice) 0))) 150 ;; See <https://bugs.gnunet.org/view.php?id=7021#c18399> for
151 ;; situations in which the deviation can be infinite or NaN.
152 (let ((stddev
153 (read% /:msg:nse:estimate '(std-deviation) slice)))
154 (or (>= stddev 0)
155 (nan? stddev)))))
151 ((handle! slice) (handle-estimate! slice))))) 156 ((handle! slice) (handle-estimate! slice)))))
152 (define (send-start!) 157 (define (send-start!)
153 ;; The service only starts sending estimates once 158 ;; The service only starts sending estimates once