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()

[((92, 108), 'numpy.power', 'np.power', (['std', '(2)'], {}), '(std, 2)\n', (100, 108), True, 'import numpy as np\n'), ((482, 499), 'numpy.sqrt', 'np.sqrt', (['variance'], {}), '(variance)\n', (489, 499), True, 'import numpy as np\n'), ((556, 579), 'numpy.arange', 'np.arange', (['(-5)', '(5)', '(0.001)'], {}), '(-5, 5, 0.001)\n', (565, 579), True, 'import numpy as np\n'), ((668, 683), 'numpy.array', 'np.array', (['gauss'], {}), '(gauss)\n', (676, 683), True, 'import numpy as np\n'), ((689, 707), 'matplotlib.pyplot.plot', 'plt.plot', (['x', 'gauss'], {}), '(x, gauss)\n', (697, 707), True, 'import matplotlib.pyplot as plt\n'), ((712, 722), 'matplotlib.pyplot.show', 'plt.show', ([], {}), '()\n', (720, 722), True, 'import matplotlib.pyplot as plt\n'), ((153, 190), 'numpy.exp', 'np.exp', (['(-0.5 * (x - mean) ** 2 / std2)'], {}), '(-0.5 * (x - mean) ** 2 / std2)\n', (159, 190), True, 'import numpy as np\n'), ((125, 150), 'numpy.sqrt', 'np.sqrt', (['(2 * np.pi * std2)'], {}), '(2 * np.pi * std2)\n', (132, 150), True, 'import numpy as np\n')]