From 373f193c6dbeef1a91ab0877dadc12a42efcf862 Mon Sep 17 00:00:00 2001 From: aryan26roy <50577809+aryan26roy@users.noreply.github.com> Date: Thu, 30 Jul 2020 01:02:36 +0530 Subject: [PATCH] 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 --- maths/gaussian.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/maths/gaussian.py b/maths/gaussian.py index 5d5800e00..a5dba50a9 100644 --- a/maths/gaussian.py +++ b/maths/gaussian.py @@ -1,9 +1,5 @@ """ Reference: https://en.wikipedia.org/wiki/Gaussian_function - -python/black : True -python : 3.7.3 - """ from numpy import exp, pi, sqrt @@ -16,6 +12,12 @@ def gaussian(x, mu: float = 0.0, sigma: float = 1.0) -> int: >>> gaussian(24) 3.342714441794458e-126 + >>> gaussian(1, 4, 2) + 0.06475879783294587 + + >>> gaussian(1, 5, 3) + 0.05467002489199788 + Supports NumPy Arrays Use numpy.meshgrid with this to generate gaussian blur on images. >>> import numpy as np @@ -49,8 +51,8 @@ def gaussian(x, mu: float = 0.0, sigma: float = 1.0) -> int: >>> gaussian(2523, mu=234234, sigma=3425) 0.0 - """ - return 1 / sqrt(2 * pi * sigma ** 2) * exp(-((x - mu) ** 2) / 2 * sigma ** 2) + """ + return 1 / sqrt(2 * pi * sigma ** 2) * exp(-((x - mu) ** 2) / (2 * sigma ** 2)) if __name__ == "__main__":