- #1
andrewr
- 263
- 0
Hi,
(Sorry for the slight misnomer in the title... I can't edit it!)
I'm doing several problems to compute the expectation value and variances of sub-samples & operations on the normal distribution; and I am having trouble getting results that agree with numerical simulations.
I have several Gaussian random generators written in C, and am using vectors of length 1million to 10billion to do numerical experiments; all generators appear to converge accurately to at least 4 decimal places with the sample sizes I am using. For example in μ(σ) notation, adding 0(1) + 0(1) gives 0(1.414), exactly as expected.
The random generator is crude, but replacement of it doesn't change the result.
Program is attached...
So, for my first (trivial) problem (and hopefully the same mistake is in my other questions!):
When I do Ʃ |0(1)|/n, I get 0.8933.
However, if I try to solve the latter problem analytically, I get a different result.
Could someone point out where I have made a mistake, please?? :)
I think the pdf for a Gaussian is:
[tex]p(x)= \sqrt{1 \over 2\pi}e^{-{1\over2}x^2}[/tex]
Since abs() only uses Half the Gaussian curve, the pdf ( w/ domain [0,∞) ) becomes:
[tex]p(x)= 2\sqrt{1 \over 2\pi}e^{-{1\over2}x^2}[/tex]
To compute the expectation value, all I ought to do is solve:
[tex]\overline{X}=\int\limits_0^{∞}x \times p(x)[/tex]
[tex]\overline{X}=2\sqrt{1\over2\pi}(\left.-e^{-0.5x^2}\right|_0^{∞})=2\sqrt{1\over2\pi}≈0.7979[/tex]
Which is, of course, wrong...
So, what did I do that messed the result up?
(Sorry for the slight misnomer in the title... I can't edit it!)
I'm doing several problems to compute the expectation value and variances of sub-samples & operations on the normal distribution; and I am having trouble getting results that agree with numerical simulations.
I have several Gaussian random generators written in C, and am using vectors of length 1million to 10billion to do numerical experiments; all generators appear to converge accurately to at least 4 decimal places with the sample sizes I am using. For example in μ(σ) notation, adding 0(1) + 0(1) gives 0(1.414), exactly as expected.
The random generator is crude, but replacement of it doesn't change the result.
Program is attached...
So, for my first (trivial) problem (and hopefully the same mistake is in my other questions!):
When I do Ʃ |0(1)|/n, I get 0.8933.
However, if I try to solve the latter problem analytically, I get a different result.
Could someone point out where I have made a mistake, please?? :)
I think the pdf for a Gaussian is:
[tex]p(x)= \sqrt{1 \over 2\pi}e^{-{1\over2}x^2}[/tex]
Since abs() only uses Half the Gaussian curve, the pdf ( w/ domain [0,∞) ) becomes:
[tex]p(x)= 2\sqrt{1 \over 2\pi}e^{-{1\over2}x^2}[/tex]
To compute the expectation value, all I ought to do is solve:
[tex]\overline{X}=\int\limits_0^{∞}x \times p(x)[/tex]
[tex]\overline{X}=2\sqrt{1\over2\pi}(\left.-e^{-0.5x^2}\right|_0^{∞})=2\sqrt{1\over2\pi}≈0.7979[/tex]
Which is, of course, wrong...
So, what did I do that messed the result up?
Attachments
Last edited: