@@ -24,20 +24,25 @@ export GaussianHermite, GaussianLaguerre, GaussianJacobi,
2424# ####################
2525
2626"""
27- GaussianHermite{β} represents a Gaussian Hermite ensemble with parameter β.
27+ GaussianHermite(β::Int) <: ContinuousMatrixDistribution
2828
29- Wigner{β} is a synonym .
29+ Represents a Gaussian Hermite ensemble with Dyson index `β` .
3030
31- Example of usage:
31+ `Wigner(β)` is a synonym.
3232
33- β = 2 #β = 1, 2, 4 generates real, complex and quaternionic matrices respectively.
34- d = Wigner{β} #same as GaussianHermite{β}
33+ ## Examples
3534
36- n = 20 #Generate square matrices of this size
35+ ```jldoctest
36+ julia> d = Wigner(2); n = 3;
3737
38- S = rand(d, n) #Generate a 20x20 symmetric Wigner matrix
39- T = tridrand(d, n) #Generate the symmetric tridiagonal form
40- v = eigvalrand(d, n) #Generate a sample of eigenvalues
38+ julia> Random.seed!(1234);
39+
40+ julia> rand(d, n)
41+ 3×3 LinearAlgebra.Hermitian{ComplexF64, Matrix{ComplexF64}}:
42+ 0.560409+0.0im -0.292145+0.125521im 1.04191+0.513798im
43+ -0.292145-0.125521im -0.346868+0.0im 0.0228835-0.00164725im
44+ 1.04191-0.513798im 0.0228835+0.00164725im -0.118721+0.0im
45+ ```
4146"""
4247struct GaussianHermite{β} <: ContinuousMatrixDistribution end
4348GaussianHermite (β) = GaussianHermite {β} ()
@@ -47,6 +52,13 @@ Synonym for GaussianHermite{β}
4752"""
4853const Wigner{β} = GaussianHermite{β}
4954
55+ """
56+ rand(d::Wigner, n::Int)
57+
58+ Generates an `n × n` matrix randomly sampled from the Gaussian-Hermite ensemble (also known as the Wigner ensemble).
59+
60+ The Dyson index `β` is restricted to `β = 1,2` or `4`, for real, complex, and quaternionic fields, respectively.
61+ """
5062rand (d:: Type{Wigner{β}} , dims... ) where {β} = rand (d (), dims... )
5163
5264function rand (d:: Wigner{1} , n:: Int )
@@ -82,12 +94,15 @@ function rand(d::Wigner{β}, dims::Int...) where {β}
8294end
8395
8496"""
85- Generates a nxn symmetric tridiagonal Wigner matrix
97+ tridand(d::Wigner, n::Int)
98+
99+ Generates an `n × n` symmetric tridiagonal matrix from the Gaussian-Hermite ensemble (also known as the Wigner ensemble).
86100
87- Unlike for `rand(Wigner{β}, n)`, which is restricted to β=1,2 or 4,
88- `trirand(Wigner{β}, n)` will generate a
101+ Unlike for `rand(Wigner(β), n)`, which is restricted to `β = 1,2` or `4`,
102+ the call `trirand(Wigner(β), n)` will generate a tridiagonal Wigner matrix for any positive
103+ value of `β`, including infinity.
89104
90- The β=∞ case is defined in Edelman, Persson and Sutton, 2012
105+ The `β == ∞` case is defined in Edelman, Persson and Sutton, 2012.
91106"""
92107function tridrand (d:: Wigner{β} , n:: Int ) where {β}
93108 χ (df:: Real ) = rand (Distributions. Chi (df))
@@ -146,16 +161,37 @@ end
146161# Laguerre ensemble #
147162# ####################
148163
164+ """
165+ GaussianLaguerre(β::Real, a::Real)` <: ContinuousMatrixDistribution
166+
167+ Represents a Gaussian-Laguerre ensemble with Dyson index `β` and `a` parameter
168+ used to control the density of eigenvalues near `λ = 0`.
169+
170+ `Wishart(β, a)` is a synonym.
171+
172+ ## Fields
173+ - `beta`: Dyson index
174+ - `a`: Parameter used for weighting the joint probability density function of the ensemble
175+
176+ ## References:
177+ - Edelman and Rao, 2005
178+ """
149179mutable struct GaussianLaguerre <: ContinuousMatrixDistribution
150180 beta:: Real
151181 a:: Real
152182end
153183const Wishart = GaussianLaguerre
154184
155-
156- # Generates a NxN Hermitian Wishart matrix
157185# TODO Check - the eigenvalue distribution looks funky
158186# TODO The appropriate matrix size should be calculated from a and one matrix dimension
187+ """
188+ rand(d::GaussianLaguerre, dims::Tuple)
189+
190+ Generate a random matrix sampled from the Gaussian Laguerre ensemble (also known as the Wishart ensemble)
191+ with parameters defined in `d` and dimensions given by `dims`.
192+
193+ The Dyson index `β` is restricted to `β = 1,2` or `4`, for real, complex, and quaternionic fields, respectively.
194+ """
159195function rand (d:: GaussianLaguerre , dims:: Dim2 )
160196 n = 2.0 * a/ d. beta
161197 if d. beta == 1 # real
@@ -172,15 +208,23 @@ function rand(d::GaussianLaguerre, dims::Dim2)
172208 return (A * A' ) / dims[1 ]
173209end
174210
175- # Generates a NxN bidiagonal Wishart matrix
211+ """
212+ bidrand(d::GaussianLaguerre, n::Int)
213+
214+ Generate an `n × n` bidiagonal matrix sampled from the Gaussian Laguerre ensemble (also known as the Wishart ensemble).
215+ """
176216function bidrand (d:: GaussianLaguerre , m:: Integer )
177217 if d. a <= d. beta* (m- 1 )/ 2.0
178218 error (" Given your choice of m and beta, a must be at least $(d. beta* (m- 1 )/ 2.0 ) (You said a = $(d. a) )" )
179219 end
180220 Bidiagonal ([chi (2 * d. a- i* d. beta) for i= 0 : m- 1 ], [chi (d. beta* i) for i= m- 1 : - 1 : 1 ], true )
181221end
182222
183- # Generates a NxN tridiagonal Wishart matrix
223+ """
224+ tridrand(d::GaussianLaguerre, n::Int)
225+
226+ Generate an `n × n` tridiagonal matrix sampled from the Gaussian Laguerre ensemble (also known as the Wishart ensemble).
227+ """
184228function tridrand (d:: GaussianLaguerre , m:: Integer )
185229 B = bidrand (d, m)
186230 L = B * B'
@@ -218,14 +262,35 @@ end
218262# Jacobi ensemble #
219263# ##################
220264
221- # Generates a NxN self-dual MANOVA matrix
265+ """
266+ GaussianJacobi(β::Real, a::Real, a::Real)` <: ContinuousMatrixDistribution
267+
268+ Represents a Gaussian-Jacobi ensemble with Dyson index `β`, while
269+ `a`and `b` are parameters used to weight the joint probability density function of the ensemble.
270+
271+ `MANOVA(β, a, b)` is a synonym.
272+
273+ ## Fields
274+ - `beta`: Dyson index
275+ - `a`: Parameter used for shaping the joint probability density function near `λ = 0`
276+ - `b`: Parameter used for shaping the joint probability density function near `λ = 1`
277+
278+ ## References:
279+ - Edelman and Rao, 2005
280+ """
222281mutable struct GaussianJacobi <: ContinuousMatrixDistribution
223282 beta:: Real
224283 a:: Real
225284 b:: Real
226285end
227286const MANOVA = GaussianJacobi
228287
288+ """
289+ rand(d::GaussianJacobi, n::Int)
290+
291+ Generate an `n × n` random matrix sampled from the Gaussian-Jacobi ensemble (also known as the MANOVA ensemble)
292+ with parameters defined in `d`.
293+ """
229294function rand (d:: GaussianJacobi , m:: Integer )
230295 w1 = Wishart (m, int (2.0 * d. a/ d. beta), d. beta)
231296 w2 = Wishart (m, int (2.0 * d. b/ d. beta), d. beta)
0 commit comments