0 | module Statistics.Erf
 1 |
 2 | import public Statistics.Norm
 3 | import public Statistics.Probability
 4 |
 5 | %default total
 6 |
 7 | --- Error function and co ---
 8 |
 9 | %foreign "C:erfc, libm 6"
10 | prim_erfc : Double -> Double
11 |
12 | export
13 | erfc : SolidDouble -> DoubleBetween 0 2
14 | erfc = roughlyFit . prim_erfc . cast
15 |
16 | export
17 | erf : SolidDouble -> DoubleBetween (-1) 1
18 | erf x = 1 - erfc x
19 |
20 | export
21 | inverfc : InvNormCDF => DoubleBetween 0 2 -> SolidDouble
22 | inverfc p = - invnormcdf (P $ p/2) / sqrt 2
23 |
24 | export
25 | inverf : InvNormCDF => DoubleBetween (-1) 1 -> SolidDouble
26 | inverf p = inverfc (1 - p)
27 |