-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtp_tdsa_3.py
30 lines (24 loc) · 896 Bytes
/
tp_tdsa_3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
size_sources =(2,1000)
sources = np.random.uniform(low=-1,high=1,size=size_sources)
A = np.array([[1,1],[0,1]])
donnees = A@sources
covar = np.cov(donnees)
vals, vecs = np.linalg.eig(covar)
inv_sqrt_vals = np.diag(1 / np.sqrt(vals))
covar_sources_inv_sqrt = vecs @ inv_sqrt_vals @ np.transpose(vecs)
Z = covar_sources_inv_sqrt@donnees
theta_values = np.linspace(0,2*np.pi,num=200)
kurtosis_list = []
for theta in theta_values :
X_estim = np.array([[np.cos(theta),-np.sin(theta)],[np.sin(theta),np.cos(theta)]])@Z
kurtosis = np.mean(X_estim**4)-3
kurtosis_list.append(kurtosis)
plt.plot(theta_values,kurtosis_list)
plt.show()
theta = 0.45
X_estim = np.array([[np.cos(theta),-np.sin(theta)],[np.sin(theta),np.cos(theta)]])@Z
sns.scatterplot(x=X_estim[0],y=X_estim[1])
plt.show()