Skip to content
Permalink
Browse files
Merge pull request #6 from jamesc/master
Fix #5 - harmonic mean throws exception when given a set of zero values
  • Loading branch information
joewilliams committed Nov 30, 2012
2 parents b1882d7 + 79782d2 commit 0da736b0e9bef2c7150cd6e6c4a9fa1854deedf9
Showing 1 changed file with 3 additions and 0 deletions.
@@ -146,6 +146,9 @@ arithmetic_mean(#scan_result{n=N, sumX=Sum}) ->
geometric_mean(#scan_result{n=N, sumLog=SumLog}) ->
math:exp(SumLog/N).

harmonic_mean(#scan_result{sumInv=0}) ->
%% Protect against divide by 0 if we have all 0 values
0;
harmonic_mean(#scan_result{n=N, sumInv=Sum}) ->
N/Sum.

0 comments on commit 0da736b

Please sign in to comment.