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

machenko_pastur #37

Open
spinkney opened this issue Jun 15, 2021 · 0 comments
Open

machenko_pastur #37

spinkney opened this issue Jun 15, 2021 · 0 comments

Comments

@spinkney
Copy link
Owner

Also see https://www.wolframalpha.com/input/?i=MarchenkoPasturDistribution

https://github.com/JuliaStats/Distributions.jl/pull/1288/files

functions {
  marchenko_pastur_pdf(real x, real Q, real sigma) {
        real q = inv_sqrt(Q);
        real b = square(sigma * (1 + q)) # Largest eigenvalue
        real a = square(sigma * (1 - q)) # Smallest eigenvalue
        
        if (x > b || x < a) return 0;
         else return ( Q * sqrt((b - x) * (x - a)) ) / ( 2 * pi() * square(sigma) * x );
  }
  
    marchenko_pastur_lpdf(real x, real Q, real sigma) {
        real q = inv_sqrt(Q);
        real b = square(sigma * (1 + q)) # Largest eigenvalue
        real a = square(sigma * (1 - q)) # Smallest eigenvalue
        
        if (x > b || x < a) return negative_infinity();
         else return log(Q) + 0.5 * ( (b - x) * (x - a) ) - 2 * sigma - log(x); //  -log(2) - log(pi()) constants removed
  }

  marchenko_pastur_cdf(real x, real Q, real sigma) {
      real b = square(sigma * (1 + q)) # Largest eigenvalue
      real a = square(sigma * (1 - q)) # Smallest eigenvalue
      real R = (b - x) * (x - a);
      
      return sqrt(R) + 
             0.5 * (a + b) * asin( (2 * x - a - b) / (b - a) ) -
             ( a * b / sqrt(a * b) ) * asin( (a + b) * x - (2 * a * b) / (x * (b - a)) );
  }
}

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

No branches or pull requests

1 participant