I have a datafile like this
Frequencies -- 95.1444 208.5295 256.0966
IR Inten -- 4.5950 0.1425 2.4807
Frequencies -- 273.7203 424.4748 446.9433
IR Inten -- 0.6420 0.0001 0.9654
Frequencies -- 520.5846 561.6770 630.1851
IR Inten -- 8.8996 6.4944 0.4674
Frequencies -- 703.7315 767.1711 799.2923
IR Inten -- 23.7514 63.4507 15.9273
Each frequency is related with the IR intensity below, for example (frequency= 95.1444/ IR Inten= 4.5950), (frequency= 208,5295/ IR Inten= 0.1425).... And so on.
I have to construct on every frequency a gaussian curve with height the relative intensity of the strongest peak. The sum of all those curves should be a model of the IR-spectrum.
Here are some hints to do it:
A gaussian curve is:
import math
y = a*math.exp(-(x-b)**2/(2*c*c))
where
a: height of the peak
b: position of the center of the peak
c: controls the width of the peak
You can plot the function as follows:
import pylab
pylab.plot(xs,ys)
# xs is a list of x-values
# ys is a list of y-values
pylab.show()
您可以使用以下库: import matplotlib.pyplot as plt
You don't have to compute every x and y values, you can do it in this way computing mean and variance:
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.mlab as mlab
import math
mu = 0
variance = 1
sigma = math.sqrt(variance)
x = np.linspace(mu - 3*sigma, mu + 3*sigma, 100)
plt.plot(x,mlab.normpdf(x, mu, sigma))
plt.show()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.