Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace approximate M values with analyically obtained ones #9

Closed
oguzhanogreden opened this issue Apr 9, 2018 · 5 comments
Closed

Replace approximate M values with analyically obtained ones #9

oguzhanogreden opened this issue Apr 9, 2018 · 5 comments

Comments

@oguzhanogreden
Copy link
Owner

@oguzhanogreden oguzhanogreden commented Apr 9, 2018

I'm following the notation of Woods & Lin (2009). M matrix is defined in page 105.

Right now this matrix is filled with approximate values. I think can obtain the exact values using moment generating functions and a bit of manual labor.

@philchalmers
Copy link

@philchalmers philchalmers commented Apr 9, 2018

These values look fine to me, they should be whole numbers under the Z ~ N(0,1) case. In what sense are they approximations?

@oguzhanogreden
Copy link
Owner Author

@oguzhanogreden oguzhanogreden commented Apr 10, 2018

I sampled a vector obs where each element was a realization of Z, then obtained mean(obs^R). I repeated this to estimate E[Z^R].

@philchalmers
Copy link

@philchalmers philchalmers commented Apr 10, 2018

That's one way to do it without the MGF. I just verified your moments using integrate(), like so:

> f <- function(Z) Z * dnorm(Z, mean=0, sd=1)
> integrate(f, -Inf, Inf)
0 with absolute error < 0
> 
> f <- function(Z) Z^2 * dnorm(Z, mean=0, sd=1)
> integrate(f, -Inf, Inf)
1 with absolute error < 1.2e-07
> 
> f <- function(Z) Z^3 * dnorm(Z, mean=0, sd=1)
> integrate(f, -Inf, Inf)
0 with absolute error < 0
> 
> f <- function(Z) Z^5 * dnorm(Z, mean=0, sd=1)
> integrate(f, -Inf, Inf)
0 with absolute error < 0
> 
> f <- function(Z) Z^6 * dnorm(Z, mean=0, sd=1)
> integrate(f, -Inf, Inf)
15 with absolute error < 7.9e-05
> 
> f <- function(Z) Z^8 * dnorm(Z, mean=0, sd=1)
> integrate(f, -Inf, Inf)
105 with absolute error < 0.0014
> 
> f <- function(Z) Z^9 * dnorm(Z, mean=0, sd=1)
> integrate(f, -Inf, Inf)
0 with absolute error < 0

This is what I was referring to before when computing the expected values beforehand for Z, which would be fairly cheap given the outer product form E(U * t(U) ), but computing the moments analytically would be more efficient.

@oguzhanogreden
Copy link
Owner Author

@oguzhanogreden oguzhanogreden commented Apr 10, 2018

A-ha, simple but effective. Didn't think of this myself. I'll work the analytical forms out this week.

@oguzhanogreden oguzhanogreden changed the title Replace apprixmate M values with analyically obtained ones Replace approximate M values with analyically obtained ones Apr 11, 2018
@oguzhanogreden
Copy link
Owner Author

@oguzhanogreden oguzhanogreden commented Apr 11, 2018

Turns out I got most correct. Only E[X^18] and E[X^20] needed adjustment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.