-
Notifications
You must be signed in to change notification settings - Fork 1
/
SyntheticProblem.py
51 lines (44 loc) · 1.09 KB
/
SyntheticProblem.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import math
import random
import numpy as np
from numpy.linalg import cholesky
import matplotlib.pyplot as plt
import pdb
import minVar
import Functions as F
from sklearn.decomposition import NMF
from sklearn.cluster import KMeans
#import movielens
import pandas as pd
Max = 100000
N = 100000
M = 100
K = 10
D = 3
Theta = np.zeros([K,D])
for a in range(K):
Theta[a,0] = 1
c = np.zeros([M,K,D])
for i in range(M):
a0 = np.random.randint(K-1)
for a in range(K):
tep = []
if a == a0:
for s in range(D):
if s == 0:
tep.append(random.random()*0.1+0.7)
else:
tep.append(random.random()*0.6/(D-1))
else:
for s in range(D):
if s == 0:
tep.append(random.random()*0.1+0.5)
else:
tep.append(random.random()*0.8/(D-1))
c[i,a] = np.array(tep)
l = 10
L = 0
for i in range(M):
for a in range(K):
if c[i,a].dot(c[i,a]) < l: l = c[i,a].dot(c[i,a])
if c[i,a].dot(c[i,a]) > L: L = c[i,a].dot(c[i,a])