Class FastGaussian


  • public class FastGaussian
    extends FastFunc
    An approximation to a univariate gaussian pdf of mean zero, deviation 1. The width of the interval over which the function is sampled is chosen as a function of the number of sample points to match the maximum error within the table (which occurs at x = 1, where the slope is maximal) with that at the boundary of the interval, outside of which the function is assumed to be identically zero. It turns out that the exact value is given by: a = sqrt(W(exp(1)*n*n)), where W(z) is the Lambert function, [-a,a] is the interval over which the function should be tabulated, and n is the number of sample points. For our purposes, the following asymptotic approximation to W(z) is sufficient: W(z) ~ ln(z) - ln(ln(z)) + ln(ln(z))/ln(z). Maximum magnitude of approximation error as a function of n: n error interval where non-zero ------ ---------- ----------------------- 100 6.89x10^-3 [-2.85 , +2.85] 1000 8.49x10^-4 [-3.51 , +3.51] 10000 9.86x10^-5 [-4.08 , +4.08] 100000 1.11x10^-5 [-4.58 , +4.58] Minimum value of n as a function of required accuracy: accuracy n -------- --------- < 10^-2 >= 66 < 10^-3 >= 838 < 10^-4 >= 9854 < 10^-5 >= 111381
    Author:
    ellis
    • Constructor Detail

      • FastGaussian

        public FastGaussian​(int samples)
    • Method Detail

      • evaluate

        public double evaluate​(double x)
        Overrides:
        evaluate in class FastFunc