[Pkg-javascript-commits] [science.js] 82/87: Fix median calculation in loess

bhuvan krishna bhuvan-guest at moszumanska.debian.org
Thu Dec 8 06:12:05 UTC 2016


This is an automated email from the git hooks/post-receive script.

bhuvan-guest pushed a commit to branch master
in repository science.js.

commit 60532b6e91661cf1d23c1cb77c4f5ff13532f992
Author: Joe Arasin <joe at arasin.com>
Date:   Wed Aug 19 16:29:15 2015 -0400

    Fix median calculation in loess
---
 science.v1.js      | 6 ++----
 science.v1.min.js  | 2 +-
 src/stats/loess.js | 6 ++----
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/science.v1.js b/science.v1.js
index e77c98d..60fc3fe 100644
--- a/science.v1.js
+++ b/science.v1.js
@@ -1416,7 +1416,7 @@ science.stats.iqr = function(x) {
 };
 // Based on org.apache.commons.math.analysis.interpolation.LoessInterpolator
 // from http://commons.apache.org/math/
-science.stats.loess = function() {    
+science.stats.loess = function() {
   var bandwidth = .3,
       robustnessIters = 2,
       accuracy = 1e-12;
@@ -1529,9 +1529,7 @@ science.stats.loess = function() {
       // Recompute the robustness weights.
 
       // Find the median residual.
-      var sortedResiduals = residuals.slice();
-      sortedResiduals.sort();
-      var medianResidual = sortedResiduals[Math.floor(n / 2)];
+      var medianResidual = science.stats.median(residuals);
 
       if (Math.abs(medianResidual) < accuracy)
         break;
diff --git a/science.v1.min.js b/science.v1.min.js
index eddc272..0557c3a 100644
--- a/science.v1.min.js
+++ b/science.v1.min.js
@@ -1 +1 @@
-(function(a){(function(a){science={version:"1.9.1"},science.ascending=function(a,b){return a-b},science.EULER=.5772156649015329,science.expm1=function(a){return a<1e-5&&a>-0.00001?a+.5*a*a:Math.exp(a)-1},science.functor=function(a){return typeof a=="function"?a:function(){return a}},science.hypot=function(a,b){a=Math.abs(a),b=Math.abs(b);var c,d;a>b?(c=a,d=b):(c=b,d=a);var e=d/c;return c*Math.sqrt(1+e*e)},science.quadratic=function(){function b(b,c,d){var e=c*c-4*b*d;return e>0?(e=Math.s [...]
\ No newline at end of file
+(function(a){(function(a){science={version:"1.9.1"},science.ascending=function(a,b){return a-b},science.EULER=.5772156649015329,science.expm1=function(a){return a<1e-5&&a>-0.00001?a+.5*a*a:Math.exp(a)-1},science.functor=function(a){return typeof a=="function"?a:function(){return a}},science.hypot=function(a,b){a=Math.abs(a),b=Math.abs(b);var c,d;a>b?(c=a,d=b):(c=b,d=a);var e=d/c;return c*Math.sqrt(1+e*e)},science.quadratic=function(){function b(b,c,d){var e=c*c-4*b*d;return e>0?(e=Math.s [...]
\ No newline at end of file
diff --git a/src/stats/loess.js b/src/stats/loess.js
index 483bb3e..2dbe9aa 100644
--- a/src/stats/loess.js
+++ b/src/stats/loess.js
@@ -1,6 +1,6 @@
 // Based on org.apache.commons.math.analysis.interpolation.LoessInterpolator
 // from http://commons.apache.org/math/
-science.stats.loess = function() {    
+science.stats.loess = function() {
   var bandwidth = .3,
       robustnessIters = 2,
       accuracy = 1e-12;
@@ -113,9 +113,7 @@ science.stats.loess = function() {
       // Recompute the robustness weights.
 
       // Find the median residual.
-      var sortedResiduals = residuals.slice();
-      sortedResiduals.sort();
-      var medianResidual = sortedResiduals[Math.floor(n / 2)];
+      var medianResidual = science.stats.median(residuals);
 
       if (Math.abs(medianResidual) < accuracy)
         break;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/science.js.git



More information about the Pkg-javascript-commits mailing list