@@ -0,0 +1,1613 @@
+/*%0A * The baseCode project%0A * %0A * Copyright (c) 2011 University of British Columbia%0A * %0A * Licensed under the Apache License, Version 2.0 (the %22License%22); you may not use this file except in compliance with%0A * the License. You may obtain a copy of the License at%0A * %0A * http://www.apache.org/licenses/LICENSE-2.0%0A * %0A * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on%0A * an %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the%0A * specific language governing permissions and limitations under the License.%0A */%0Apackage ubic.basecode.math;%0A%0Aimport java.util.LinkedList;%0Aimport java.util.Queue;%0A%0Aimport cern.colt.matrix.DoubleMatrix1D;%0A%0A/**%0A * Methods for moving averages etc.%0A * %0A * @author paul%0A * @version $Id$%0A */%0Apublic class Smooth %7B%0A%0A    public static DoubleMatrix1D movingAverage( DoubleMatrix1D m, int windowSize ) %7B%0A%0A        Queue%3CDouble%3E window = new LinkedList%3CDouble%3E();%0A%0A        double sum = 0.0;%0A%0A        assert windowSize %3E 0;%0A%0A        DoubleMatrix1D result = m.like();%0A        for ( int i = 0; i %3C m.size(); i++ ) %7B%0A%0A            double num = m.get( i );%0A            sum += num;%0A            window.add( num );%0A            if ( window.size() %3E windowSize ) %7B%0A                // this is bad because at the beginning, we're averaging too few points, and at the end we're%0A                sum -= window.remove();%0A            %7D%0A%0A            if ( !window.isEmpty() ) %7B%0A                result.set( i, sum / window.size() );%0A            %7D%0A        %7D%0A%0A        return result;%0A%0A    %7D%0A%0A%7D%0A

replace faulty built-in moving average with my own implementation