Skip to content

Instantly share code, notes, and snippets.

@patricoferris
Created April 20, 2019 07:45
Show Gist options
  • Save patricoferris/d7521634b91dfc7cf0b5091263c0b810 to your computer and use it in GitHub Desktop.
Save patricoferris/d7521634b91dfc7cf0b5091263c0b810 to your computer and use it in GitHub Desktop.
# The function that defines are Guassian function for a
# random variable X who is normally distrubted with
# mean 'm' and standard deviation 's'
def guass_func(x, m, s):
a = 1 / (s * ((2 * math.pi) ** 0.5))
b = -0.5 * (((x - m) / s) ** 2)
return a * math.exp(b)
# Generate a linearly spaced range of x-values from -5 to 5 (1000 of them)
xs = np.linspace(-5, 5, 1000)
# Map our Guassian function with mean 0 and standard deviation 1 over each x in the range
ys = list(map(lambda x: guass_func(x, 0, 1), xs))
# We can then go on to plot this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment