Need code for Inverse Error Function

前端 未结 7 1883
清歌不尽
清歌不尽 2021-02-10 00:54

Does anyone know where I could find code for the \"Inverse Error Function?\" Freepascal/Delphi would be preferable but C/C++ would be fine too.

The TMath/DMath library d

7条回答
  •  忘了有多久
    2021-02-10 01:46

    Pascal Programs for Scientists and Engineers has the gaussian Error function (erf) and its complement erfc=(1-errf), but not the Inverse of the Error function. Obviously, you don't just take 1/ErrF. The inverse means x = erfinv(y) satisfies y = erf(x).

    http://infohost.nmt.edu/~armiller/pascal.htm

    Error function and its complement, are shown in this listing.

    Again, the definition of Error Function Complement is 1-ErrF, not ErrF^-1, but this has got to be getting you close:

    http://infohost.nmt.edu/~es421/pascal/list11-3.pas

    I found this interesting implementation (language unknown, I'm guessing it's matlab). maybe it and its coefficients can help you:

    http://w3eos.whoi.edu/12.747/mfiles/lect07/erfinv.m

    Another PDF here: http://people.maths.ox.ac.uk/~gilesm/files/gems_erfinv.pdf

    Relevant snippet:

    Table 1: Pseudo-code to compute y = erfinv(x) , with p1(t)..p6(t) representing a 1st through 6th polynomial function of t :

    a = |x|        
    if a > 0.9375 then
    t = sqrt( log(a) )
    y = p1(t) / p2(t)
    else if a > 0.75 then
    y = p3(a) / p4(a)
    else
    y = p5(a) / p6(a)
    end if
    if x < 0 then
    y = −y
    end if
    

    Apparently the library code functions by approximation, it's less work. Sometimes the approximations are to less than 6 decimal places accuracy, I read.

    Fortran code that many people use for a reference, is here, it cites "Rational Chebyshev approximations for the error function" by W. J. Cody, Math. Comp., 1969, PP. 631-638.:

提交回复
热议问题