import numpy as np
import matplotlib.pyplot as plt


def gaussian(x, mean, std):
    std2 = np.power(std, 2)
    return (1 / np.sqrt(2* np.pi * std2)) * np.exp(-.5 * (x - mean)**2 / std2)


if __name__ == "__main__":
    gauss_1 = gaussian(10, 8, 2) # 0.12098536225957168
    gauss_2 = gaussian(10, 10, 2) # 0.19947114020071635

    print("Gauss(10, 8, 2): {}".format(gauss_1))
    print("Gauss(10, 10, 2): {}".format(gauss_2))

    # 標準高斯分佈
    mean = 0
    variance = 1
    std = np.sqrt(variance)

    # Plot between -10 and 10 with .001 steps.
    x = np.arange(-5, 5, 0.001)
    gauss = []
    for i in x:
        gauss.append(gaussian(i, mean, std))
    gauss = np.array(gauss)

    plt.plot(x, gauss)
    plt.show()

[((6, 11, 6, 27), 'numpy.power', 'np.power', ({(6, 20, 6, 23): 'std', (6, 25, 6, 26): '2'}, {}), '(std, 2)', True, 'import numpy as np\n'), ((20, 10, 20, 27), 'numpy.sqrt', 'np.sqrt', ({(20, 18, 20, 26): 'variance'}, {}), '(variance)', True, 'import numpy as np\n'), ((23, 8, 23, 31), 'numpy.arange', 'np.arange', ({(23, 18, 23, 20): '-5', (23, 22, 23, 23): '5', (23, 25, 23, 30): '0.001'}, {}), '(-5, 5, 0.001)', True, 'import numpy as np\n'), ((27, 12, 27, 27), 'numpy.array', 'np.array', ({(27, 21, 27, 26): 'gauss'}, {}), '(gauss)', True, 'import numpy as np\n'), ((29, 4, 29, 22), 'matplotlib.pyplot.plot', 'plt.plot', ({(29, 13, 29, 14): 'x', (29, 16, 29, 21): 'gauss'}, {}), '(x, gauss)', True, 'import matplotlib.pyplot as plt\n'), ((30, 4, 30, 14), 'matplotlib.pyplot.show', 'plt.show', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((7, 44, 7, 78), 'numpy.exp', 'np.exp', ({(7, 51, 7, 77): '(-0.5 * (x - mean) ** 2 / std2)'}, {}), '(-0.5 * (x - mean) ** 2 / std2)', True, 'import numpy as np\n'), ((7, 16, 7, 40), 'numpy.sqrt', 'np.sqrt', ({(7, 24, 7, 39): '(2 * np.pi * std2)'}, {}), '(2 * np.pi * std2)', True, 'import numpy as np\n')]