Here you can find the source of differenceFunction(float[] data, int windowLength)
public static float[] differenceFunction(float[] data, int windowLength)
//package com.java2s; /*//www .j a v a2s. co m * Copyright (c) 2008-2013 Maksim Khadkevich and Fondazione Bruno Kessler. * * This file is part of MART. * MART is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2, as published * by the Free Software Foundation. * * MART is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with MART; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ public class Main { public static float[] differenceFunction(float[] data, int windowLength) { float[] diffFunction = new float[data.length]; float sum; for (int t = 0; t < data.length; t++) { sum = 0; for (int j = 0; j < Math.min(j + windowLength, data.length - t); j++) { sum += Math.pow(data[j] - data[j + t], 2); } diffFunction[t] = sum; } return diffFunction; } public static float[] pow(float[] inData, float rate) { float[] out = new float[inData.length]; for (int i = 0; i < inData.length; i++) { out[i] = (float) Math.pow(inData[i], rate); } return out; } }