We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6c82fb2 commit 0a8cc54Copy full SHA for 0a8cc54
spectral/algorithms/resampling.py
@@ -34,10 +34,32 @@
34
35
from __future__ import division, print_function, unicode_literals
36
37
+def erf_local(x):
38
+ import math
39
+ # save the sign of x
40
+ sign = 1 if x >= 0 else -1
41
+ x = abs(x)
42
+
43
+ # constants
44
+ a1 = 0.254829592
45
+ a2 = -0.284496736
46
+ a3 = 1.421413741
47
+ a4 = -1.453152027
48
+ a5 = 1.061405429
49
+ p = 0.3275911
50
51
+ # A&S formula 7.1.26
52
+ t = 1.0/(1.0 + p*x)
53
+ y = 1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*math.exp(-x*x)
54
+ return sign*y # erf(-x) = -erf(x)
55
56
try:
57
from math import erf
58
except:
- from scipy.special import erf
59
+ try:
60
+ from scipy.special import erf
61
+ except:
62
+ erf = erf_local
63
64
def erfc(z):
65
'''Complement of the error function.'''
0 commit comments