MCPcopy Create free account
hub / github.com/SINGROUP/dscribe / gaussian

Method gaussian

dscribe/ext/mbtr.cpp:434–456  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

432}
433
434inline vector<double> MBTR::gaussian(double center, double weight, double start, double dx, double sigmasqrt2, int n) {
435
436 // We first calculate the cumulative distibution function for a normal
437 // distribution.
438 vector<double> cdf(n+1);
439 double x = start;
440 for (auto &it : cdf) {
441 it = weight*1.0/2.0*(1.0 + erf((x-center)/sigmasqrt2));
442 x += dx;
443 }
444
445 // The normal distribution is calculated as a derivative of the cumulative
446 // distribution, as with coarse discretization this methods preserves the
447 // norm better.
448 vector<double> pdf(n);
449 int i = 0;
450 for (auto &it : pdf) {
451 it = (cdf[i+1]-cdf[i])/dx;
452 ++i;
453 }
454
455 return pdf;
456}
457
458inline vector<double> MBTR::xgaussian(double center, double weight, double start, double dx, double sigma, int n) {
459

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected