Skip to content

Commit

Permalink
Fix for incorrect weighted mean calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
wssbck committed Sep 14, 2014
1 parent d3568fe commit a550f10
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions crossfilter-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ var exports = (function(e){
return {
add : function(p, v){
p.count += w(v);
p.sum += w(v) ? fn_f(v) : 0;
p.sum += fn_f(v) * w(v);
p.mean = p.count ? p.sum / p.count : 0;
return p;
},
remove : function(p, v){
p.count -= w(v);
p.sum -= w(v) ? fn_f(v) : 0;
p.sum -= fn_f(v) * w(v);
p.mean = p.count ? p.sum / p.count : 0;
return p;
},
Expand Down
2 changes: 1 addition & 1 deletion crossfilter-helpers.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "crossfilter-helpers",
"version": "0.2.0",
"version": "0.2.1",
"license": "Apache-2.0",
"description": "A set of reduction functions for use with crossfilter",
"keywords": [
Expand Down
4 changes: 2 additions & 2 deletions src/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ var exports = (function(e){
return {
add : function(p, v){
p.count += w(v);
p.sum += w(v) ? fn_f(v) : 0;
p.sum += fn_f(v) * w(v);
p.mean = p.count ? p.sum / p.count : 0;
return p;
},
remove : function(p, v){
p.count -= w(v);
p.sum -= w(v) ? fn_f(v) : 0;
p.sum -= fn_f(v) * w(v);
p.mean = p.count ? p.sum / p.count : 0;
return p;
},
Expand Down

0 comments on commit a550f10

Please sign in to comment.