From: Christian Grothoff Date: Wed, 23 Nov 2011 18:48:46 +0000 (+0000) Subject: fixing variance calculation - we calculate the average from the same distribution... X-Git-Tag: initial-import-from-subversion-38251~15832 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5d2ea67c611975319dba37741dc6561cce3a9559;p=oweals%2Fgnunet.git fixing variance calculation - we calculate the average from the same distribution, so the degrees of freedom is n-1 --- diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index 61ab7e57a..a0140ca28 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c @@ -349,7 +349,7 @@ setup_estimate_message (struct GNUNET_NSE_ClientMessage *em) for (i = 0; i < estimate_count; i++) { - int j; + unsigned int j; j = (estimate_index - i + HISTORY_SIZE) % HISTORY_SIZE; val = htonl (size_estimate_messages[j].matching_bits); @@ -359,9 +359,9 @@ setup_estimate_message (struct GNUNET_NSE_ClientMessage *em) if (0 != estimate_count) { mean = sum / estimate_count; - variance = (vsq - mean * sum) / estimate_count; // terrible for numerical stability... + variance = (vsq - mean * sum) / (estimate_count - 1.0); // terrible for numerical stability... GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "(%f - %f) / %u = %f\n", - vsq, mean * sum, estimate_count, variance); + vsq, mean * sum, estimate_count - 1, variance); } #endif