In searching for divide-by-zero issues, I discovered that negative numbers are non considered a non-zero value for analysis, nor are they added to the total (which then affects the average. Patch forthcoming...

Comments

danchadwick’s picture

Status: Active » Needs review
StatusFileSize
new2.03 KB

This patch fixes the bug and cleans up the code a bit.

1) Counts negative number in statistics.
2) Renames $nonzero and $not_empty to $non_zero and $non_empty for consistency.
3) Uses (float)$value to handle empty strings. No special handling is needed: http://www.php.net/manual/en/language.types.string.php#language.types.st...

The only slight remaining weirdness that I see is that the option to consider empty/zero is used to switch from a straight std dev to a sample std dev by dividing by N-1. I'm not sure that this is justified, especially in the case where there are no non-empty value. See http://en.wikipedia.org/wiki/Standard_deviation. If it's thought that this isn't the best solution, another issue should be created. I don't purport to be a statistics expert.

danchadwick’s picture

Status: Needs review » Fixed

Committed #1 to 7.x-4.x and backported to 7.x-3.x and 6.x

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

fenstrat’s picture

Version: 7.x-4.x-dev » 8.x-4.x-dev
Assigned: danchadwick » fenstrat
Status: Closed (fixed) » Patch (to be ported)

Needs porting to 8.x-4.x.

fenstrat’s picture

Version: 8.x-4.x-dev » 7.x-4.x-dev
Assigned: fenstrat » danchadwick
Status: Patch (to be ported) » Fixed

Committed and pushed 7197be5 to 8.x-4.x. Thanks!

  • Commit e5e676a on 8.x-4.x authored by DanChadwick, committed by fenstrat:
    Issue #2204273 by DanChadwick: Analysis incorrect for negative numbers.
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.