Skip to content

Commit 373f193

Browse files
aryan26roycclauss
andauthored
Correcting the Gaussian Formula (#2249)
* Correcting the Gaussian Formula I have added the parenthesis around the 2*sigma^2 term. * Update gaussian.py * Update gaussian.py * Update gaussian.py * Update gaussian.py * Update gaussian.py * Update gaussian.py Co-authored-by: Christian Clauss <[email protected]>
1 parent c7a5f16 commit 373f193

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Diff for: maths/gaussian.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
"""
22
Reference: https://en.wikipedia.org/wiki/Gaussian_function
3-
4-
python/black : True
5-
python : 3.7.3
6-
73
"""
84
from numpy import exp, pi, sqrt
95

@@ -16,6 +12,12 @@ def gaussian(x, mu: float = 0.0, sigma: float = 1.0) -> int:
1612
>>> gaussian(24)
1713
3.342714441794458e-126
1814
15+
>>> gaussian(1, 4, 2)
16+
0.06475879783294587
17+
18+
>>> gaussian(1, 5, 3)
19+
0.05467002489199788
20+
1921
Supports NumPy Arrays
2022
Use numpy.meshgrid with this to generate gaussian blur on images.
2123
>>> import numpy as np
@@ -49,8 +51,8 @@ def gaussian(x, mu: float = 0.0, sigma: float = 1.0) -> int:
4951
5052
>>> gaussian(2523, mu=234234, sigma=3425)
5153
0.0
52-
"""
53-
return 1 / sqrt(2 * pi * sigma ** 2) * exp(-((x - mu) ** 2) / 2 * sigma ** 2)
54+
"""
55+
return 1 / sqrt(2 * pi * sigma ** 2) * exp(-((x - mu) ** 2) / (2 * sigma ** 2))
5456

5557

5658
if __name__ == "__main__":

0 commit comments

Comments
 (0)