- #1
dacruick
- 1,042
- 1
Hi I have a program that is to calculate the area under the curve of a Gaussian distribution.
The integral from -inf to inf is 1, and my Reimann sum program calculates close to 1.5pi = numpy.arccos(-1)
a = 1 / (StandDev * pow(2*pi,0.5))
b = MPCAverage #MPC is the x-axis of my gaussian curve
c = StandDev
step = 0.01
IntervalSize = 1.27 #Irrelevant
x2 = 0
s = 0
while s < IntervalSize/step:
x1 = x2
x2 += step
y1 = a*numpy.exp(-(x1-b)**2/(c*c*2))
y2 = a*numpy.exp(-(x2-b)**2/(c*c*2))
Area += (step)*(y2+y1/2)
s += 1
print Area
any tips would be greatly appreciated. Sorry for the spacing error, it won't let me put them in.
The integral from -inf to inf is 1, and my Reimann sum program calculates close to 1.5pi = numpy.arccos(-1)
a = 1 / (StandDev * pow(2*pi,0.5))
b = MPCAverage #MPC is the x-axis of my gaussian curve
c = StandDev
step = 0.01
IntervalSize = 1.27 #Irrelevant
x2 = 0
s = 0
while s < IntervalSize/step:
x1 = x2
x2 += step
y1 = a*numpy.exp(-(x1-b)**2/(c*c*2))
y2 = a*numpy.exp(-(x2-b)**2/(c*c*2))
Area += (step)*(y2+y1/2)
s += 1
print Area
any tips would be greatly appreciated. Sorry for the spacing error, it won't let me put them in.