Integral of Gaussian function, for squared x

In summary: Wait, I just realized something. I was thinking that you could take the variance out of the integral, then compute the integral, and then multiply the 2 back in. However, my thinking was wrong. You can't take the sigma out of the integral, because it is part of the p(x) function, and the integral is with respect to x, not sigma. So, it looks like I was right the first time, and the answer should be 1. If you compute the integral with the sigma still in there, you get an answer of \sigma^3 \sqrt(2 \pi) / 2. Then, when you multiply it by 2, you get \sigma^3 \sqrt(2 \
  • #1
Avinto
3
0

Homework Statement


I am trying to compute an integral, as part of the expected value formula (using a Gaussian PDF)

[tex]\int_{-∞}^{∞} (x)^2 p(x) dx [/tex]

Where p(x) is the Gaussian probability density function:
[tex]\frac{1}{\sigma \sqrt(2 \pi)} \exp(\frac{-x^2}{2 \sigma^2})[/tex]

My aim after this is to be able to compute for all even x^n in the above formula. For all odd x^n, the positive and negative componets cancel out, with an computation of zero for all odd functions.


Homework Equations


Wikipedia lists two equations that relate to this:
[1]https://en.wikipedia.org/wiki/List_of_integrals_of_Gaussian_functions

[1]
[tex]\int_{-∞}^{∞} (x)^2 \phi(x)^n dx = \frac{1}{\sqrt(n^3 (2 \pi)^{n-1})} [/tex]

and
[2]https://en.wikipedia.org/wiki/List_of_integrals_of_exponential_functions

[2]
The range here is zero to infinity, however as this function is even, the result for minus infinity to infinity should be twice what the below computes.
[tex]\int_{0}^{∞} (x)^n \exp(-\alpha x^2) dx= \frac{(2 k -1)!}{2^{k+1} \alpha^k} \sqrt(\frac{\pi}{\alpha})[/tex]
Where
[tex]n=2 k, k integer, \alpha > 0[/tex]

The Attempt at a Solution


Using [1], I can compute a answer equalling 1, which is apparently the right answer. However when using [2] (where k=1), I compute a different anwser:

Compute:
Let [tex]\alpha = \frac{1}{2 \sigma^2}[/tex]
and
[tex]k=1[/tex]

then:
[tex]\int_{0}^{∞} (x)^2 \exp(-\alpha x^2) dx = \frac{(2 k -1)!}{2^{k+1} \alpha^k} \sqrt(\frac{\pi}{\alpha})[/tex]

[tex]=\frac{1!}{4 \alpha}\sqrt(\frac{\pi}{\alpha})[/tex]

[tex]=\frac{\sigma^2}{2}\sqrt(2 \sigma^2 \pi)[/tex]

[tex]=\frac{\sigma^2}{2} \sigma \sqrt(2 \pi)[/tex]

[tex]=\frac{\sigma^3 \sqrt(2 \pi)}{2} [/tex]

Now, this is where I think I messed up. I previously removed
[tex]\frac{1}{\sigma \sqrt(2 \pi)}[/tex]
from inside the integral, and attempted to multiply it by the obtained result (and then doubled everything, as it is an even function)

[tex]2 \frac{1}{\sigma \sqrt(2 \pi)} \frac{\sigma^3 \sqrt(2 \pi)}{2} [/tex]

Then by cancelling:
[tex]=\sigma [/tex]

I'm thinking this is because I took part of the PDF out of the integral, and then changed the limits. However, I'm not sure how to go about working this out while leaving it in there.

I will keep browsing around for a solution to this problem (and the more general x^n), and would really appreciate any hints on this.

Thanks.
 
Physics news on Phys.org
  • #2
Avinto said:

Homework Statement


I am trying to compute an integral, as part of the expected value formula (using a Gaussian PDF)

[tex]\int_{-∞}^{∞} (x)^2 p(x) dx [/tex]

Where p(x) is the Gaussian probability density function:
[tex]\frac{1}{\sigma \sqrt(2 \pi)} \exp(\frac{-x^2}{2 \sigma^2})[/tex]

My aim after this is to be able to compute for all even x^n in the above formula. For all odd x^n, the positive and negative componets cancel out, with an computation of zero for all odd functions.


Homework Equations


Wikipedia lists two equations that relate to this:
[1]https://en.wikipedia.org/wiki/List_of_integrals_of_Gaussian_functions

[1]
[tex]\int_{-∞}^{∞} (x)^2 \phi(x)^n dx = \frac{1}{\sqrt(n^3 (2 \pi)^{n-1})} [/tex]

and
[2]https://en.wikipedia.org/wiki/List_of_integrals_of_exponential_functions

[2]
The range here is zero to infinity, however as this function is even, the result for minus infinity to infinity should be twice what the below computes.
[tex]\int_{0}^{∞} (x)^n \exp(-\alpha x^2) dx= \frac{(2 k -1)!}{2^{k+1} \alpha^k} \sqrt(\frac{\pi}{\alpha})[/tex]
Where
[tex]n=2 k, k integer, \alpha > 0[/tex]

The Attempt at a Solution


Using [1], I can compute a answer equalling 1, which is apparently the right answer. However when using [2] (where k=1), I compute a different anwser:

Compute:
Let [tex]\alpha = \frac{1}{2 \sigma^2}[/tex]
and
[tex]k=1[/tex]

then:
[tex]\int_{0}^{∞} (x)^2 \exp(-\alpha x^2) dx = \frac{(2 k -1)!}{2^{k+1} \alpha^k} \sqrt(\frac{\pi}{\alpha})[/tex]

[tex]=\frac{1!}{4 \alpha}\sqrt(\frac{\pi}{\alpha})[/tex]

[tex]=\frac{\sigma^2}{2}\sqrt(2 \sigma^2 \pi)[/tex]

[tex]=\frac{\sigma^2}{2} \sigma \sqrt(2 \pi)[/tex]

[tex]=\frac{\sigma^3 \sqrt(2 \pi)}{2} [/tex]

Now, this is where I think I messed up. I previously removed
[tex]\frac{1}{\sigma \sqrt(2 \pi)}[/tex]
from inside the integral, and attempted to multiply it by the obtained result (and then doubled everything, as it is an even function)

[tex]2 \frac{1}{\sigma \sqrt(2 \pi)} \frac{\sigma^3 \sqrt(2 \pi)}{2} [/tex]

Then by cancelling:
[tex]=\sigma [/tex]

I'm thinking this is because I took part of the PDF out of the integral, and then changed the limits. However, I'm not sure how to go about working this out while leaving it in there.

I will keep browsing around for a solution to this problem (and the more general x^n), and would really appreciate any hints on this.

Thanks.

First get
[tex] I_n = \int_0^{\infty} x^n \phi(x) \, dx, \:\: \phi(x) =
\frac{1}{\sqrt{2 \pi}} e^{-x^2/2},[/tex]
then obtain the general result by re-scaling the variable. Note that ##x \phi(x) \, dx = d(-\phi(x))## so we can use integration by parts:
[tex] \int x^n \phi(x) \, dx = \int u dv,\\
u = x^{n-1}, \: dv = x \phi(x) \, dx = d(-\phi(x))[/tex]
 
  • #3
Alternatively, change variables to ##t = x^2## and use the definition of the Gamma function.
 
  • #4
Thank you for your suggestions.

Ray, I will attempt to work it out using your way later today, and see how it goes.

Orodruin, I have had a go at your method, but have not had much luck.

[tex] t = x^2[/tex]

[tex] \Gamma(z) = \int_0^{∞} t^{z-1} exp(-t) dt [/tex]

[tex] \Gamma(3) = \int_0^{∞} t^{3-1} \exp(-t) dt [/tex]

[tex] \Gamma(3) = (3-1)! = 2 [/tex]

Then for the range [itex]{-∞,0}[/itex], this answer should be the same, so I get an answer of 4 overall.I'm working under the assumption that the answer should be 1
 
Last edited:
  • #5
Well, the answer cannot be 1. It should be the variance of the distribution (since the expectation value is zero). In fact, you had it (almost) right in your first post... Also note that in the substitution, z is not 3. If you do it correctly, z should have a half-integer value (which is why you end up with a semi-factorial and 2^(k+1)).

Edit: Well, of course the answer would be one if the variance is ... :)
 
  • #6
Orodruin said:
Well, the answer cannot be 1. It should be the variance of the distribution (since the expectation value is zero). In fact, you had it (almost) right in your first post... Also note that in the substitution, z is not 3. If you do it correctly, z should have a half-integer value (which is why you end up with a semi-factorial and 2^(k+1)).

Edit: Well, of course the answer would be one if the variance is ... :)

Ok, I see what you mean about the variance, the definition of [itex]\phi[/itex] on the wiki page assumes [itex]\sigma=1[/itex]. Using [itex]\sigma=1[/itex], my calculation did evaluate to one, which is where I must have gotten that assumption from.

I redid my calculations with including [itex]\sigma[/itex], and realized I made a silly error in my cancellation.
[tex]2 \frac{1}{\sigma \sqrt(2 \pi)} \frac{\sigma^3 \sqrt(2 \pi)}{2} [/tex]

Should evaluate to [itex]\sigma^2[/itex], not [itex]\sigma[/itex].

I will look more into the Gamma function as well, and try to understand it from that direction. Thanks
 

1. What is the formula for the integral of a Gaussian function for squared x?

The formula for the integral of a Gaussian function for squared x is ∫e-x2dx.

2. Why is the Gaussian function commonly used in science and mathematics?

The Gaussian function is commonly used in science and mathematics because it is a bell-shaped curve that accurately describes many natural phenomena and can be easily manipulated mathematically.

3. How is the integral of a Gaussian function related to probability?

The integral of a Gaussian function is directly related to probability through the area under the curve. The total area under the curve is equal to 1, and the probability of a certain event occurring is represented by the area under the curve within a specific range of x values.

4. Can the integral of a Gaussian function be solved analytically?

Yes, the integral of a Gaussian function can be solved analytically using the error function, which is a special function used to solve integrals involving the Gaussian function.

5. How is the integral of a Gaussian function used in data analysis?

The integral of a Gaussian function is commonly used in data analysis to fit a curve to a set of data points. This allows for the estimation of parameters such as the mean and standard deviation, which can then be used to make predictions about the data.

Similar threads

  • Calculus and Beyond Homework Help
Replies
1
Views
348
  • Calculus and Beyond Homework Help
Replies
8
Views
876
  • Calculus and Beyond Homework Help
Replies
5
Views
360
  • Calculus and Beyond Homework Help
2
Replies
47
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
160
  • Calculus and Beyond Homework Help
Replies
12
Views
1K
  • Calculus and Beyond Homework Help
Replies
3
Views
1K
  • Calculus and Beyond Homework Help
Replies
3
Views
563
  • Calculus and Beyond Homework Help
Replies
10
Views
375
  • Calculus and Beyond Homework Help
Replies
1
Views
220
Back
Top