This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
public class KMeans { | |
public static double distance(double x[], double y[]) { | |
int D = x.length; | |
double distance = 0; | |
for(int i = 0; i < D; i++) { | |
distance += Math.pow(x[i] - y[i], 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LongestCommonSubsequence { | |
public static int length(String x, String y) { | |
int N = x.length(); | |
int M = y.length(); | |
int lcs[][] = new int[N + 1][M + 1]; | |
for(int i = 1; i < N + 1; i++) { | |
for(int j = 1; j < M + 1; j++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RecerseAString { | |
public static String reverse(String string) { | |
char str[] = string.toCharArray(); | |
for(int i = 0; i < str.length / 2; i++) { | |
char tmp = str[i]; | |
str[i] = str[str.length - 1 - i]; | |
str[str.length - 1 - i] = tmp; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BinarySearch { | |
public static int search(int[] sorted, int element) { | |
int min = 0; | |
int max = sorted.length; | |
while(max > min) { | |
int mid = min + (max - min) / 2; | |
if(sorted[mid] == element) { | |
return element; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package prediction; | |
import org.apache.commons.math3.linear.Array2DRowRealMatrix; | |
import org.apache.commons.math3.linear.ArrayRealVector; | |
/** | |
* Item based interpolation | |
* | |
* @author Daniel Kohlsdorf | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package analysis.preprocessing; | |
import java.util.HashMap; | |
import java.util.Vector; | |
import database.OhuraDB; | |
import database.indexing.LocalFeature; | |
/** | |
* Topic Modeling using the Latent Dirichlet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package processing.utils; | |
/** | |
* Utilities to compute log probabilities | |
* | |
* @author Daniel Kohlsdorf | |
*/ | |
public class ProbabilityUtils { | |
public static final double ZERO = Double.NEGATIVE_INFINITY; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package processing.signals; | |
import java.util.ArrayList; | |
import processing.utils.ProbabilityUtils; | |
/** | |
* Viterbi Style Whistle Tracing | |
* | |
* @author Daniel Kohlsdorf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package processing.inference; | |
import java.util.ArrayList; | |
import java.util.Vector; | |
import processing.model.Gaussian; | |
import processing.model.GaussianMixture; | |
import processing.model.HiddenMarkovModel; | |
import processing.model.ProbabilityDistibution; | |
import processing.utils.ProbabilityUtils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package processing.inference; | |
import java.util.ArrayList; | |
import processing.model.HiddenMarkovModel; | |
import processing.utils.ProbabilityUtils; | |
/** | |
* Inference algorithms used for training and decoding hidden markov models. |