Let the standard deviation of the empty set be 0. This is consistent with

the behaviour for averages, and fixes a crash that can occur when attempting
to print a stddev aggregation containing no elements:

    dtrace:::BEGIN { @ = stddev(0); clear(@); printa("%@d", @); }

PR:		197260
MFC after:	2 week
This commit is contained in:
Mark Johnston 2015-02-02 20:48:31 +00:00
parent 174b32ced4
commit 6ac0e4858a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=278114

View File

@ -382,6 +382,9 @@ dt_stddev(uint64_t *data, uint64_t normal)
int64_t norm_avg;
uint64_t diff[2];
if (data[0] == 0)
return (0);
/*
* The standard approximation for standard deviation is
* sqrt(average(x**2) - average(x)**2), i.e. the square root