Skip to content

Commit

Permalink
Merge pull request apache#6 from jamesc/master
Browse files Browse the repository at this point in the history
Fix apache#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 0da736b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/bear.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit 0da736b

Please sign in to comment.