File tree 2 files changed +12
-4
lines changed
src/java/com/bigml/histogram
test/bigml/histogram/test
2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -339,10 +339,12 @@ public SumResult<T> extendedSum(double p) throws SumOutOfRangeException {
339
339
bin_i1 = new Bin (_maximum , 0 , emptyTarget .clone ());
340
340
}
341
341
342
- double prevCount = 0 ;
343
- T prevTargetSum = (T ) emptyTarget .clone ();
344
-
345
- if (bin_i .getMean () != _minimum ) {
342
+ double prevCount ;
343
+ T prevTargetSum ;
344
+ if (bin_i .getMean () == _minimum ) {
345
+ prevCount = _bins .first ().getCount () / 2 ;
346
+ prevTargetSum = (T ) _bins .first ().getTarget ().clone ().mult (0.5 );
347
+ } else {
346
348
SumResult <T > prevSumResult = getPointToSumMap ().get (bin_i .getMean ());
347
349
prevCount = prevSumResult .getCount ();
348
350
prevTargetSum = prevSumResult .getTargetSum ();
Original file line number Diff line number Diff line change 342
342
343
343
(deftest nil-target-sum
344
344
(is (nil? (total-target-sum (create )))))
345
+
346
+ (deftest sum-edges
347
+ (let [hist (reduce insert! (create ) [0 10 ])]
348
+ (is (== 1 (sum hist 5 )))
349
+ (is (== 0.5 (sum hist 0 )))
350
+ (is (== 2 (sum hist 10 )))))
You can’t perform that action at this time.
0 commit comments