Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Gaussian integration

  1. Feb 19, 2008 #1
    I'm trying to integrate the Gaussian distribution between arbitrary limits, but I'm not having a lot of luck. As far as I can see I've done it right, but the answer I get is imaginary, which is obviously wrong, since it's supposed to represent a probability :confused:

    1. The problem statement, all variables and given/known data

    a = 299
    b = 301
    β = -6.4e-6
    α = sqrt(-β/π)

    2. Relevant equations

    http://img442.imageshack.us/img442/8195/croppercapture2jk3.png [Broken]

    3. The attempt at a solution
    Steps I'm taking:
    1. Turn it into a double integral over x and y
    2. Transform to polar coordinates; dxdy becomes rdrdθ and the limits become the corresponding values of r and θ for x=b, x=a (do I need to do something else with the θ limits perhaps?)
    3. Evaluate the r (inner) integral (with respect to r) and bring it outside the outer integral as a coefficient, since it's constant (is this part right? I'm not quite sure)
    4. Evaluate the θ integral; this just becomes θ(b) - θ(a).

    Here's my working:

    http://img208.imageshack.us/img208/5830/croppercapture6iq4.png [Broken]

    Using this approach, I get an answer of 0.513e-5 i, which is clearly wrong (it should be around 2.84e-3).

    Can anyone tell me what I'm doing wrong? :(
    Last edited by a moderator: May 3, 2017
  2. jcsd
  3. Feb 19, 2008 #2
    Seems like you're sorta forgetting a pretty important negative sign
  4. Feb 19, 2008 #3
    Whoops, I meant to put β = -6.4e-6 in my first post. That's what I used in the calculation, though, and it still gives me an imaginary number. Basically the minus sign that's normally in front of the x² in a Gaussian distribution is contained in β (to make the algebra simpler).
  5. Feb 19, 2008 #4
    Damn, I was hoping it'd be something simple so I wouldn't feel the compulsive need to carefully check your work >_>

    Forget checking it by plugging in your numbers, everyone and their mother knows the solution when x runs from negative infinity to infinity(or 0 to infinity if you prefer the factor of 1/2)so I'm thinking actually the problem, since your work seems ok, is gonna be in those limits of integration

    I'm looking at those relevant equations you listed, and I'm thinking you kinda judiciously misused y, in that r=sqrt(x^2+y^2), like you use when you make the double integral, that y doesn't refer to the given function, it's like a dummy variable. You didn't have to call it y at all, you could've called it anything, but with x and y being used it makes it glaringly obvious what variable substitution makes it doable
  6. Feb 22, 2008 #5
    That's one of the things I was considering, but by my understanding of the technique, you choose the dummy variable y to be the actual function that you're integrating, as this means that the polar coordinate system you transform to will correspond directly to Cartesian system that the function was defined in.

    Since you only know the limits in x, you also need to know y in terms of x in order to find the limits in r and θ. Choosing the dummy variable as y = αexp(βx²) allows you to do just this.

    I've only ever seen this done over (-∞,∞), which means that you don't have to worry about transforming limits in such detail, but this technique seems like it should work to give the same results.

    That's my understanding of it anyway; I stand to be corrected :tongue:
    Last edited: Feb 22, 2008
  7. Feb 22, 2008 #6


    User Avatar
    Homework Helper

    This is rather irrelevant to the discussion, but what program did you use to write and display maths symbol as pictures?
  8. Feb 22, 2008 #7
    Uh..are we sure this is analytically doable? I just dug up pages and pages on this integral and the closest I could find is from 0 to a, and it can't be solved in closed form
  9. Feb 22, 2008 #8


    User Avatar
    Science Advisor
    Homework Helper

    It's not analytically doable unless you just call it the erf(x) function and then call that analytical. You can do special cases like 0 -> infinity using tricks like Inquistus is using (e.g. over an annular region in the plane) but that doesn't help you over a general interval [a,b].
  10. Feb 22, 2008 #9
    I guess it might not be, but even if it's not, I'd still be interested to know why my technique isn't valid.

    Word 2007. I rather like the equation editor it has :redface:
  11. Feb 22, 2008 #10
    Right, I get it now. The reason this only works for special cases like [0,∞) is that the area beneath the curve in Cartesian coordinates happens to be equal to the area enclosed by the curve in polar coordinates. However, for an arbitrary interval [a,b], this isn't necessarily the case.

    Thanks for the help!
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook