Skip to content

Instantly share code, notes, and snippets.

@suvojit-0x55aa
Created August 1, 2019 12:39
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suvojit-0x55aa/fdbaeade2618ac302ec85dfa5f01f9e9 to your computer and use it in GitHub Desktop.
Save suvojit-0x55aa/fdbaeade2618ac302ec85dfa5f01f9e9 to your computer and use it in GitHub Desktop.
Python Numpy Gaussian Function
def gauss_map(size_x, size_y=None, sigma_x=5, sigma_y=None):
if size_y == None:
size_y = size_x
if sigma_y == None:
sigma_y = sigma_x
assert isinstance(size_x, int)
assert isinstance(size_y, int)
x0 = size_x // 2
y0 = size_y // 2
x = np.arange(0, size_x, dtype=float)
y = np.arange(0, size_y, dtype=float)[:,np.newaxis]
x -= x0
y -= y0
exp_part = x**2/(2*sigma_x**2)+ y**2/(2*sigma_y**2)
return 1/(2*np.pi*sigma_x*sigma_y) * np.exp(-exp_part)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment