| 432 | } |
| 433 | |
| 434 | inline 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 | |
| 458 | inline vector<double> MBTR::xgaussian(double center, double weight, double start, double dx, double sigma, int n) { |
| 459 |
nothing calls this directly
no outgoing calls
no test coverage detected