Skip to content

Instantly share code, notes, and snippets.

@tsutarou10
Created October 31, 2017 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsutarou10/5bc5ae9fd5967da4c65b7463a9ebe8e1 to your computer and use it in GitHub Desktop.
Save tsutarou10/5bc5ae9fd5967da4c65b7463a9ebe8e1 to your computer and use it in GitHub Desktop.
ガウス基底関数
#coding: utf-8
import numpy as np
import matplotlib.pyplot as plt
def phi(x,mu,s):
return np.exp(-(pow(x-mu,2))/(2*pow(s,2)))
if __name__ == "__main__":
N = 1000
x = np.linspace(-1,1, N)
mu = [0.2*(i-5) if i > 5 else 0.2 * (-i) for i in range(11)]
sigma = [0.1 for i in range(11)]
for m,s in zip(mu,sigma):
y = phi(x,m,s)
plt.plot(x,y)
plt.title("Gaussian Basis function")
plt.savefig("gaussianBasis.png")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment