Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Daniel Kohlsdorf dkohlsdorf

🏠
Working from home
View GitHub Profile
View DynamicTimeWarping.java
package processing.segmentation;
import java.util.ArrayList;
/**
* Compute the Dynamic Time Warping Distance
*
* @author Daniel Kohlsdorf
*/
public class DynamicTimeWarping {
@dkohlsdorf
dkohlsdorf / HMMInference.java
Last active Mar 13, 2019
Hidden Markov Model Inference
View HMMInference.java
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.
@dkohlsdorf
dkohlsdorf / HMMTraining.java
Last active Mar 13, 2019
Hidden Markov Model Training
View HMMTraining.java
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;
View MotionWhistleTracerViterbi.java
package processing.signals;
import java.util.ArrayList;
import processing.utils.ProbabilityUtils;
/**
* Viterbi Style Whistle Tracing
*
* @author Daniel Kohlsdorf
@dkohlsdorf
dkohlsdorf / ProbabilityUtils.java
Last active Mar 13, 2019
Probability Calculations Numerically Stable
View ProbabilityUtils.java
package processing.utils;
/**
* Utilities to compute log probabilities
*
* @author Daniel Kohlsdorf
*/
public class ProbabilityUtils {
public static final double ZERO = Double.NEGATIVE_INFINITY;
@dkohlsdorf
dkohlsdorf / LDA.java
Last active Mar 13, 2019
Latent Dirichlet Allocations
View LDA.java
package analysis.preprocessing;
import java.util.HashMap;
import java.util.Vector;
import database.OhuraDB;
import database.indexing.LocalFeature;
/**
* Topic Modeling using the Latent Dirichlet
View MatrixFactorization.java
package prediction;
import org.apache.commons.math3.linear.Array2DRowRealMatrix;
import org.apache.commons.math3.linear.ArrayRealVector;
/**
* Item based interpolation
*
* @author Daniel Kohlsdorf
*/
View BinarySearch.java
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;
View ReverseString.java
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;
}
@dkohlsdorf
dkohlsdorf / LCS.java
Last active Mar 13, 2019
Longest Common Subsequence
View LCS.java
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++) {
You can’t perform that action at this time.