• API
• FAQ
• Tools
• Archive
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. def getGaussian(xvect, mewk, sigmak):
2.
3.     xi = np.zeros((l,1))
4.     for i in range(len(xi)):
5.         xi[i][0] = xvect[i]
6.     #print(xi)
7.
8.     det_sigmak = np.linalg.det(sigmak)
9.     det_sigmak = np.absolute(det_sigmak)
10.     # print("sigmak",sigmak)
11.     # print("det_sigmak",det_sigmak)
12.
13.     if(det_sigmak == 0):
14.         print("determinant zero")
15.         det_sigmak = 0.0000001
16.
17.     inv_sigmak = np.linalg.inv(sigmak)
18.     constant = 1.0 / (np.sqrt((np.power(2*np.pi,l)) * det_sigmak))
19.     #print("deno const",np.sqrt((np.power(2*np.pi,dim)) * det_sigmak))
20.     #print("constant:", constant)
21.
22.     #print("xi", xi)
23.     #print("mewk", mewk)
24.
25.     xi_min_mewk = np.subtract(xi,mewk)
26.
27.     # print(xi_min_mewk,"\nhh",inv_sigmak)
28.
29.     #print("trans",np.transpose(xi_min_mewk))
30.     #print("inve sigmak", inv_sigmak)
31.     temp = np.dot(np.transpose(xi_min_mewk),inv_sigmak)
32.     #print("temp",temp)
33.     #print("ximinmewk", xi_min_mewk)
34.     exp_val = np.dot(temp,xi_min_mewk)
35.     exp_val = -0.5 * exp_val
36.     #print("exp val:",exp_val)
37.
38.     #print("sigmak",sigmak)
39.
40.     #print(np.multiply(5,mewk))
41.
42.     if(exp_val < -500):
43.         exp_val = -500
44.     elif (exp_val > 500):
45.         exp_val = 500
46.
47.     ans = constant*np.exp(exp_val)
48.     #print("gaussian",ans)
49.     return ans
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top