mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r1212316 - in /mahout/trunk/core/src: main/java/org/apache/mahout/cf/taste/impl/common/WeightedRunningAverage.java test/java/org/apache/mahout/cf/taste/impl/common/WeightedRunningAverageTest.java
Date Fri, 09 Dec 2011 10:09:05 GMT
Author: srowen
Date: Fri Dec  9 10:09:04 2011
New Revision: 1212316

URL: http://svn.apache.org/viewvc?rev=1212316&view=rev
Log:
MAHOUT-919 fixed result of WeightedRunningAverage.addDatum(double, double) when it is the
first call

Modified:
    mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/WeightedRunningAverage.java
    mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/common/WeightedRunningAverageTest.java

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/WeightedRunningAverage.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/WeightedRunningAverage.java?rev=1212316&r1=1212315&r2=1212316&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/WeightedRunningAverage.java
(original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/common/WeightedRunningAverage.java
Fri Dec  9 10:09:04 2011
@@ -40,7 +40,7 @@ public class WeightedRunningAverage impl
     double oldTotalWeight = totalWeight;
     totalWeight += weight;
     if (oldTotalWeight <= 0.0) {
-      average = datum * weight;
+    	average = datum;
     } else {
       average = average * oldTotalWeight / totalWeight + datum * weight / totalWeight;
     }

Modified: mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/common/WeightedRunningAverageTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/common/WeightedRunningAverageTest.java?rev=1212316&r1=1212315&r2=1212316&view=diff
==============================================================================
--- mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/common/WeightedRunningAverageTest.java
(original)
+++ mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/common/WeightedRunningAverageTest.java
Fri Dec  9 10:09:04 2011
@@ -32,10 +32,10 @@ public final class WeightedRunningAverag
 
     assertEquals(0, runningAverage.getCount());
     assertTrue(Double.isNaN(runningAverage.getAverage()));
-    runningAverage.addDatum(1.0);
-    assertEquals(1.0, runningAverage.getAverage(), EPSILON);
     runningAverage.addDatum(1.0, 2.0);
     assertEquals(1.0, runningAverage.getAverage(), EPSILON);
+    runningAverage.addDatum(1.0);
+    assertEquals(1.0, runningAverage.getAverage(), EPSILON);
     runningAverage.addDatum(8.0, 0.5);
     assertEquals(2.0, runningAverage.getAverage(), EPSILON);
     runningAverage.addDatum(-4.0);



Mime
View raw message