N EMO
N EMO

Reputation: 93

How can I make ring from Gaussian distribution

enter image description here

I saw the formula for making a ring from Gaussian on https://arxiv.org/pdf/1606.05908.pdf but it did not work, and I found another formula which makes sphere(ring) from normal distribution

enter image description here

it is maked by using GCN. I used this algorithm to make a ring from a normal distribution but it also did not work.

please help me

Upvotes: 4

Views: 1528

Answers (3)

Mou
Mou

Reputation: 165

Transferring the Gaussian blob to be a ring is to redesign where the exponential function will be ONE. We can make it by deciding where the coordinate equals ZERO.

ring_radius = 10;
x,y  = np.meshgrid(np.linspace(-16,15,32),np.linspace(-16,15,32))
ring = np.exp(-(np.sqrt(x**2+y**2)-ring_loc)**2);
io.inshow(ring):

enter image description here

Upvotes: 0

Haizhou
Haizhou

Reputation: 19

I will provide a simpler but faster version of this algorithm:

import numpy as np
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))

and Z is the result you want.

Upvotes: 0

Matt Messersmith
Matt Messersmith

Reputation: 13767

The first example works just fine. Here's the relevant python code:

import matplotlib.pyplot as plt
import numpy as np

# Create and plot multivariate normal distribution
mean = [0, 0]
cov = [[1,0],[0,1]]
x, y = np.random.multivariate_normal(mean, cov, 100).T
plt.figure(1)
plt.plot(x, y, 'x')
plt.axis('equal')

# Generate z    
def g(xy):
    res_z = []
    for z in xy:
        z = np.array(z)
        res_z.append(z / 10 + z / np.linalg.norm(z))
    return res_z
xy = zip(x, y)
res_z = g(xy)

# Plot z
zx, zy = zip(*res_z)
plt.figure(2)
plt.plot(zx, zy, 'x')
plt.axis('equal')
plt.show()

and this outputs (if you click and drag the figures to the position shown below):

multivariate gaussian remapped to circle

Note that when you run the script, your output will be slightly different, since np.random.multivariate_normal is doing random sampling from the underlying distribution (mean [0,0], identity covariance matrix).

I'm on Anaconda 5.1.0, Python 3.6.

HTH.

Upvotes: 1

Related Questions