N1H111SM's Miniverse

Data Simulation Cookbook

字数统计: 117阅读时长: 1 min
2020/05/31 Share

Multi-Variate Gaussion

Need to provide the mean and covariance matrix.

1
2
3
4
mean = [0, 0]
cov = [[1, 0], [0,1]]
data_size = 100
X = np.random.multivariate_normal(mean, cov, data_size)

2D-ring

Produce a ring for given $(x, y, r)$ triplet. The first one use the famous formula adopted in VAE.

1
2
3
def ring(x, y, r, data_size):,
X = np.random.multivariate_normal([0, 0], [[1, 0], [0,1]], data_size)
Z = X / 10 + X / np.sqrt(np.square(X).sum(axis=1, keepdims=True))

3D-globule

Produce len(centers) gaussian globules.

1
2
3
4
5
6
7
8
def globule_3d(centers, datasize):
res = []
for center in centers:
offsets = []
for _ in range(3):
offsets.append(np.random.normal(0.,1.,datasize).reshape([datasize,1]))
res.append(center + np.hstack(offsets))
return res
CATALOG
  1. 1. Multi-Variate Gaussion
  2. 2. 2D-ring
  3. 3. 3D-globule