Skip to content

Commit

Permalink
Bugfix sigma value
Browse files Browse the repository at this point in the history
  • Loading branch information
BDoignies committed May 14, 2024
1 parent dfa774c commit beb232c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions include/utk/metrics/GaussianKernels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ namespace utk
const double PI = 3.141592653589793238462;
const unsigned int N = pts.Npts();
const unsigned int D = pts.Ndim();
const double scaledSigma = sigma * std::pow(N, 1.0 / D);
const double invSigma = - 1.0 / (2.0 * scaledSigma * scaledSigma);
const double norm = PI * scaledSigma * scaledSigma / (2.0 * N);
const double invN = 1.0 / N;
const double scaledSigma = sigma * std::pow(N, -1.0 / D);
const double invSigma = - 1.0 / (4.0 * scaledSigma * scaledSigma);
const double norm = PI * scaledSigma * scaledSigma / N;
// const double invN = 1.0 / N;

double value = 0.;

Expand All @@ -76,11 +76,11 @@ namespace utk
for (OPENMP_UINT l = 0; l < N; l++)
{
const double weight = std::exp(invSigma * dist(pts.Ndim(), pts[k], pts[l]));
value += weight * norm * invN;
value += weight * norm;
}
}

return value;
return value - 4 * PI * PI * scaledSigma * scaledSigma * scaledSigma * scaledSigma;
}

template<typename T>
Expand Down
2 changes: 1 addition & 1 deletion src/metrics/GaussianKernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int main(int argc, char** argv)
bool euclidean = false;
double sigma = 1.0;
app.add_flag("--euclidean", euclidean, "Use euclidean distance (default is wrap around)")->default_val(euclidean);
app.add_flag("--sigma", sigma, "Variance of gaussians (relative to nominal grid N^(1/D))")->default_val(sigma);
app.add_option("--sigma", sigma, "Variance of gaussians (relative to nominal grid N^(1/D))")->default_val(sigma);

CLI11_PARSE(app, argc, argv);

Expand Down

0 comments on commit beb232c

Please sign in to comment.