Search code examples
pythonnormalizationnormal-distribution

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


Solution

  • 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.