Skip to content

Instantly share code, notes, and snippets.

@si14
Created September 23, 2013 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save si14/6676599 to your computer and use it in GitHub Desktop.
Save si14/6676599 to your computer and use it in GitHub Desktop.
(defn gaussian [m mu gamma]
(let [m (mp/clone m)
t (/ 1 (* gamma (Math/sqrt (* 2 Math/PI))))]
(magic/specialize :double
(loop-over [m]
(let [x (aget m-data m-idx)
exparg (* -0.5 (Math/pow (/ (- x mu) gamma) 2))
g (* t (Math/exp exparg))]
(aset m-data m-idx g))))))
def gen_vector(n):
return np.array([float(x) / n for x in range(n)])
def gaussian1(m, mu, gamma):
t = 1. / (gamma * (2 * np.pi) ** 0.5)
exparg = -0.5 * (((m - mu) / gamma) ** 2)
return np.exp(exparg) * t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment