Skip to content

Commit bd55af6

Browse files
committed
Adds bidiagonal representations
1 parent 7c48711 commit bd55af6

File tree

2 files changed

+67
-39
lines changed

2 files changed

+67
-39
lines changed

src/GaussianEnsembleDistributions.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ function HermiteJPDF{Eigenvalue<:Number}(lambda::Vector{Eigenvalue}, beta::Real)
4343
end
4444

4545

46-
4746
#TODO Check m and ns
4847
function LaguerreJPDF{Eigenvalue<:Number}(lambda::Vector{Eigenvalue}, n::Unsigned, beta::Real)
4948
m = length(lambda)

src/GaussianEnsembleSamples.jl

Lines changed: 67 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ using Distributions
1717
export GaussianHermiteMatrix, GaussianLaguerreMatrix, GaussianJacobiMatrix,
1818
GaussianHermiteTridiagonalMatrix, GaussianLaguerreTridiagonalMatrix,
1919
GaussianJacobiSparseMatrix,
20-
GaussianHermiteSamples, GaussianLaguerreSamples, GaussianJacobiSamples
20+
GaussianHermiteSamples, GaussianLaguerreSamples, GaussianJacobiSamples,
21+
chi, GaussianLaguerreBidiagonalMatrix, GaussianJacobiBidiagonalMatrix
2122

2223

2324
#########################
@@ -36,49 +37,56 @@ chi(df) = df==0? 0.0 : sqrt(rand(Chisq(df)))
3637
function GaussianHermiteMatrix(n::Integer, beta::Integer)
3738
if beta == 1 #real
3839
A = randn(n, n)
39-
normalization = sqrt(2*n)
4040
elseif beta == 2 #complex
4141
A = randn(n, n) + im*randn(n, n)
42-
normalization = sqrt(4*n)
4342
elseif beta == 4 #quaternion
4443
#Employs 2x2 matrix representation of quaternions
4544
X = randn(n, n) + im*randn(n, n)
4645
Y = randn(n, n) + im*randn(n, n)
47-
A = [X Y; -conj(Y) conj(X)]
48-
normalization = sqrt(8*n) #TODO check normalization
46+
A = [X Y -conj(Y) conj(X)]
4947
else
50-
error(@sprintf("beta = %d is not implemented", beta))
48+
throw(string("beta = ", beta, " is not implemented"))
5149
end
52-
return (A + A') / normalization
50+
return (A + A') / sqrt(2*beta*n)
5351
end
5452

53+
5554
#Generates a NxN tridiagonal Wigner matrix
5655
#The beta=infinity case is defined in Edelman, Persson and Sutton, 2012
5756
function GaussianHermiteTridiagonalMatrix(n::Integer, beta::Real)
58-
if beta<=0 error("beta must be positive") end
59-
if beta==Inf return SymTridiagonal(zeros(n), [sqrt(x/2) for x=n-1:-1:1]) end
60-
Hdiag = randn(n)/sqrt(n)
61-
Hsup = [chi(beta*i)/sqrt(2*n) for i=n-1:-1:1]
57+
if beta<0 error("beta must be non-negative") end
58+
if beta==Inf return SymTridiagonal(zeros(n), Float64[sqrt(x/n) for x=n-1:-1:1]) end
59+
nrm = 1/sqrt(beta*n) #normalization
60+
Hdiag = randn(n)*nrm
61+
Hsup = [chi(beta*i)*nrm for i=n-1:-1:1]
6262
return SymTridiagonal(Hdiag, Hsup)
6363
end
6464

65+
66+
#Return n eigenvalues distributed according to the Hermite ensemble
67+
function GaussianHermiteSamples(n::Integer, beta::Real)
68+
eigvals(GaussianHermiteTridiagonalMatrix(n, beta))
69+
end
70+
71+
6572
##############################
6673
# Gaussian Wishart ensemble #
6774
# Gaussian Laguerre ensemble #
6875
##############################
6976

7077
#Generates a NxN Hermitian Wishart matrix
71-
#TODO Check - the eigenvalue distribution looks funky
72-
function GaussianLaguerreMatrix(m::Integer, n::Integer, beta::Integer)
78+
#n: exterior dimension of matrix
79+
#m: "interior" dimension of the matrix
80+
function GaussianLaguerreMatrix(n::Integer, m::Integer, beta::Integer)
7381
if beta == 1 #real
74-
A = randn(m, n)
82+
A = randn(n, m)
7583
elseif beta == 2 #complex
76-
A = randn(m, n) + im*randn(m, n)
84+
A = randn(n, m) + im*randn(n, m)
7785
elseif beta == 4 #quaternion
7886
#Employs 2x2 matrix representation of quaternions
79-
X = randn(m, n) + im*randn(m, n)
80-
Y = randn(m, n) + im*randn(m, n)
81-
A = [X Y; -conj(Y) conj(X)]
87+
X = randn(n, m) + im*randn(n, m)
88+
Y = randn(n, m) + im*randn(n, m)
89+
A = [X Y -conj(Y) conj(X)]
8290
error(@sprintf("beta = %d is not implemented", beta))
8391
end
8492
return (A * A') / m
@@ -87,12 +95,12 @@ end
8795

8896
#Generates a NxN bidiagonal Wishart matrix
8997
#Laguerre ensemble
90-
function GaussianLaguerreBidiagonalMatrix(m::Integer, a::Real, beta::Real)
91-
min_a = beta*(m-1)/2
92-
a<min_a ? error(@sprintf("Given your choice of m and beta, a must be at least %f (You said a = %f)", min_a, a)) : nothing
93-
Hdiag = [chi(2*a-i*beta) for i=0:m-1]
94-
Hsub = [chi(beta*i) for i=m-1:-1:1]
95-
Bidiagonal(Hsub, Hdiag, false)/(m^0.25)
98+
function GaussianLaguerreBidiagonalMatrix(n::Integer, a::Real, beta::Real)
99+
min_a = beta*(n-1)/2
100+
a<min_a ? error(@sprintf("Given your choice of n and beta, a must be at least %f (You said a = %f)", min_a, a)) : nothing
101+
Hdiag = [chi(2*a-i*beta) for i=0:n-1]
102+
Hsub = [chi(beta*i) for i=n-1:-1:1]
103+
Bidiagonal(Hdiag, Hsub, false)/sqrt(n)
96104
end
97105

98106

@@ -104,21 +112,35 @@ function GaussianLaguerreTridiagonalMatrix(m::Integer, a::Real, beta::Real)
104112
end
105113

106114

107-
#Return n eigenvalues distributed according to the Hermite ensemble
108-
function GaussianHermiteSamples(n::Integer, beta::Real)
109-
eigvals(GaussianHermiteTridiagonalMatrix(n, beta))
115+
#Return n eigenvalues distributed according to the Laguerre ensemble
116+
#Compute the singular values of the bidiagonal matrix
117+
function GaussianLaguerreSamples(m::Integer, a::Real, beta::Real)
118+
svdvals(GaussianLaguerreBidiagonalMatrix(m, a, beta))
110119
end
111120

121+
#The limiting density of states for an infinite matrix
122+
#This is the Marčenko-Pastur law
123+
#Marčenko, V.A. and Pastur, L.A. (1967). Distribution of eigenvalues for some sets of random
124+
# matrices. Sbornik: Mathematics 1, 457–483.
125+
function GaussianLaguerreDensity(n::Integer, m::Integer, beta::Real, x::Real)
126+
GaussianLaguerreDensity(n/m, beta, x)
127+
end
128+
function GaussianLaguerreDensity(c::Real, beta::Real, x::Real)
129+
#There is also a finite mass at 0 for c>1 of weight (1 - 1/c)
130+
if c>1 && x==0 return Inf
131+
am, ap = beta*(1-sqrt(c))^2, beta*(1-sqrt(c))^2
132+
sqrt((x-am)*(ap-x))/(2*pi*beta*x*c)
133+
end
112134

113135
############################
114136
# Gaussian MANOVA ensemble #
115137
# Jacobi ensemble #
116138
############################
117139

118140
#Generates a NxN self-dual MANOVA Matrix
119-
function GaussianJacobiMatrix(m::Integer, n1::Integer, n2::Integer, beta::Integer)
120-
w1 = Wishart(m, n1, beta)
121-
w2 = Wishart(m, n2, beta)
141+
function GaussianJacobiMatrix(n::Integer, m1::Integer, m2::Integer, beta::Integer)
142+
w1 = Wishart(n, m1, beta)
143+
w2 = Wishart(n, m2, beta)
122144
return (w1 + w2) \ w1
123145
end
124146

@@ -142,13 +164,6 @@ function SampleCSValues(n::Integer, a::Real, b::Real, beta::Real)
142164
end
143165

144166

145-
#Return n eigenvalues distributed according to the Laguerre ensemble
146-
#Compute the singular values of the bidiagonal matrix
147-
function GaussianLaguerreSamples(m::Integer, a::Real, beta::Real)
148-
svdvals(GaussianLaguerreBidiagonalMatrix(m, a, beta))
149-
end
150-
151-
152167
#Generates a 2Mx2M sparse MANOVA matrix
153168
#Jacobi ensemble
154169
#
@@ -218,4 +233,18 @@ function GaussianJacobiSamples(n::Integer, a::Real, b::Real, beta::Real)
218233
svdvals(GaussianJacobiBidiagonalMatrix(n, a, b))
219234
end
220235

221-
236+
#Returns limiting density of states for an infinite-dimensional matrix
237+
#A generalization of Marcenko-Pastur
238+
function GaussianJacobiDensity(n::Integer, m1::Integer, m2::Integer, beta::Real, x::Real)
239+
GaussianJacobiDensity(n/m1, n/m2, beta, x)
240+
end
241+
function GaussianJacobiDensity(c1::Real, c2::Real, beta::Real, x::Real)
242+
if !(0<=c1<=1) error(string("Need 0<=c1<=1 but you have c1=", c1)) end
243+
if !(beta==1) error(string("beta!=1 not implemented")) end
244+
#Finite mass at 0 of weight (1-1/c2)
245+
if c2>1 && x==0 return Inf
246+
b0=c1*x-c2*x-c1+2
247+
b1=-2c2*x^2+2x-3c1*x+c1+c2*x-1+2c1*x^2
248+
b2=c1*x-2c1*x^2+c2*x^2-x^3*c2+x^3*c1
249+
sqrt(4b2*b0-b1^2)/(2*pi*b2)
250+
end

0 commit comments

Comments
 (0)