from pylab import*
cener = 5
sigma = 1
coeff = 1/sqrt(2*pi)*sigma
gauss_list = []
for x in arange(0,10,0.1):
gauss = coeff*exp(-(x-center)**2/(2. *sigma **2))
gauss_list.append(gauss)
plot(gauss_list)
show()
from pylab import*
center = 0
sigma = 1
gauss_list=[]
k = 1
z=[]
for x in arange(-pi,pi,pi/128):
gauss = sin(k*x)
gaus_list.append(gauss)
z.append(x)
plot(z,gauss_list)
show()
from pylab import *
A= 1
w = 1
Fourier_seriers = []
for i in range(1,3):
x = []
sine_function = []
for t in arange(-3.14,3.14,0.01)
sine_function.append(sine_function)
x.append(t)
Fourier_Seriesappend(sine_fucntion)
superposition = zeros(len(sine_function))
for function in Fourier_Series:
for i in range(len(fucntion)):
fuperposition[i]
plot(x,superpositon)
from pylab import* #Need this for plotting functions
Number=50center = 0 #Define the center of the gaussian constants
sigma = 1 #set the standard deviation to 1
coeff = 1 / sqrt(2*pi)*sigma #This is the normalization
coefficientstgauss_list = [] #Create a rom list of the values in the Gaussian
#Calculation loop
for x in arange(0,Number,0.1): #Loop from 0 to 10 by 0.1
gauss = coeff * exp (-(x-center)**2/(2. * sigma **2)) #Find the Gaussian gauss_list.append(gauss) #Add the calcualted values to the list of values#plot(gauss_list) #Plot the values
#Define the Amplitude of the Sine Functionw = 1 #Set the frequency coefficientFourier_Series = [] #Iniialize the list of sine functions#Calculate the harmonics of the sine functions
for i in range(1,Number): x = [] #This will let us plot the values from -pi to pi sine_function = [] #This contains the sine function for t in arange (-3.14,3.14,0.01): #loop from 0 to 10 by 0.1 sine_f = gauss_list[i-1] * sin(i*w*t) #Calculate the sine sine_function.append(sine_f) x.append(t) #plot(x,sine_function) #Plot the values Fourier_Series.append(sine_function)
superposition = zeros(len(sine_function)) #set as zeros of length equal to the sine
for function in Fourier_Series: for i in range(len(function)): superposition[i] += function[i]
plot (x,superposition)
show () #Show the plots
沒有留言:
張貼留言