-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnormaldistrib.py
45 lines (32 loc) · 1.16 KB
/
normaldistrib.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import numpy as np
from scipy.special import erfc
__version__ = "1.0.0"
def erfv(x, slope=20, scale=1, sep=5, center=0):
x = np.asanyarray(x)
return scale * (
0.5 * erfc(slope * (x - center + sep)) + 0.5 * erfc(slope * (-x + sep + center))
)
def erfvd(x, slope=20, scalea=1, scaleb=1, sep=5, center=0):
x = np.asanyarray(x)
return scalea * 0.5 * erfc(slope * (x - center + sep)) + scaleb * 0.5 * erfc(
slope * (-x + sep + center)
)
def gaussian(x, center, tau, scale):
x = np.asanyarray(x)
return (
scale
* (np.exp(-((x - center) ** 2) / 2 / tau / tau))
/ np.sqrt(2 * np.pi)
/ tau
)
def erfv_stepr(x, slope=20, scale=1, sep=5, center=0):
x = np.asanyarray(x)
return scale * (0.5 * erfc(slope * (-x + sep + center)))
def erfv_stepl(x, slope=20, scale=1, sep=5, center=0):
x = np.asanyarray(x)
return scale * (0.5 * erfc(slope * (x - center + sep)))
def mserf(x, slope=20, scale=1, sep=5, center=0, halfwidth=60):
return (
erfv_stepr(x, slope, scale, sep, center - (halfwidth + 1))
* erfv_stepl(x, slope, scale, sep, center + (halfwidth + 1))
) ** 0.5