Skip to content

Commit

Permalink
Implement chisquare for average-profile weighted matrix for #1442
Browse files Browse the repository at this point in the history
  • Loading branch information
koheiw committed Oct 4, 2018
1 parent 0f74e48 commit 7c873c8
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions src/simil_mt.cpp
Expand Up @@ -157,24 +157,9 @@ double dist_euclidean(colvec& col_i, colvec& col_j) {
}

double dist_chisquare(colvec& col_i, colvec& col_j) {
//double s1 = accu(col_i);
//double s2 = accu(col_j);
//double q = accu(square((col_i / s1) - (col_j / s2)) * (1 / sum(col_i + col_j, 0)));
double s1 = accu(col_i);
double s2 = accu(col_j);
colvec p = (col_i + col_j) / (s1 + s2);

//Rcout << col_i / s1 << "\n";
//Rcout << p << "\n";

col_i = col_i / s1 / p;
col_j = col_j / s2 / p;

return accu(col_i) + accu(col_j) - (2 * accu(col_i * trans(col_j)));

//double q = accu(square(col_i - col_j) * pow(sum(col_i + col_j, 0) / (s1 + s2), -1));
//double q = accu(square(col_i - col_j) * (1 / sum(col_i + col_j, 0) / (s1 + s2)));
//return sqrt(s1 + s2) * sqrt(q);
double s1 = accu(square(col_i));
double s2 = accu(square(col_j));
return (s1 + s2) - accu(2 * trans(col_i) * col_j);
}

double dist_hamming(colvec& col_i, colvec& col_j) {
Expand Down

0 comments on commit 7c873c8

Please sign in to comment.