@@ -24,20 +24,21 @@ 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
37-
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
35+ ```@example
36+ julia> rand(Wigner(2), 3)
37+ 3×3 LinearAlgebra.Hermitian{ComplexF64, Matrix{ComplexF64}}:
38+ 0.383322+0.0im -0.0452508+0.491032im -0.313208-0.330435im
39+ -0.0452508-0.491032im -0.264521+0.0im -0.131337+0.0904235im
40+ -0.313208+0.330435im -0.131337-0.0904235im -0.481758+0.0im
41+ ```
4142"""
4243struct GaussianHermite{β} <: ContinuousMatrixDistribution end
4344GaussianHermite (β) = GaussianHermite {β} ()
@@ -47,6 +48,13 @@ Synonym for GaussianHermite{β}
4748"""
4849const Wigner{β} = GaussianHermite{β}
4950
51+ """
52+ rand(d::Wigner, n::Int)
53+
54+ Generates an `n × n` matrix randomly sampled from the Gaussian-Hermite ensemble (also known as the Wigner ensemble).
55+
56+ The Dyson index `β` is restricted to `β = 1,2` or `4`, for real, complex, and quaternionic fields, respectively.
57+ """
5058rand (d:: Type{Wigner{β}} , dims... ) where {β} = rand (d (), dims... )
5159
5260function rand (d:: Wigner{1} , n:: Int )
@@ -82,12 +90,15 @@ function rand(d::Wigner{β}, dims::Int...) where {β}
8290end
8391
8492"""
85- Generates a nxn symmetric tridiagonal Wigner matrix
93+ tridand(d::Wigner, n::Int)
94+
95+ Generates an `n × n` symmetric tridiagonal matrix from the Gaussian-Hermite ensemble (also known as the Wigner ensemble).
8696
87- Unlike for `rand(Wigner{β}, n)`, which is restricted to β=1,2 or 4,
88- `trirand(Wigner{β}, n)` will generate a
97+ Unlike for `rand(Wigner(β), n)`, which is restricted to `β = 1,2` or `4`,
98+ the call `trirand(Wigner(β), n)` will generate a tridiagonal Wigner matrix for any positive
99+ value of `β`, including infinity.
89100
90- The β=∞ case is defined in Edelman, Persson and Sutton, 2012
101+ The `β == ∞` case is defined in Edelman, Persson and Sutton, 2012.
91102"""
92103function tridrand (d:: Wigner{β} , n:: Int ) where {β}
93104 χ (df:: Real ) = rand (Distributions. Chi (df))
@@ -146,16 +157,37 @@ end
146157# Laguerre ensemble #
147158# ####################
148159
160+ """
161+ GaussianLaguerre(β::Real, a::Real)` <: ContinuousMatrixDistribution
162+
163+ Represents a Gaussian-Laguerre ensemble with Dyson index `β` and `a` parameter
164+ used to control the density of eigenvalues near `λ = 0`.
165+
166+ `Wishart(β, a)` is a synonym.
167+
168+ ## Fields
169+ - `beta`: Dyson index
170+ - `a`: Parameter used for weighting the joint probability density function of the ensemble
171+
172+ ## References:
173+ - Edelman and Rao, 2005
174+ """
149175mutable struct GaussianLaguerre <: ContinuousMatrixDistribution
150176 beta:: Real
151177 a:: Real
152178end
153179const Wishart = GaussianLaguerre
154180
155-
156- # Generates a NxN Hermitian Wishart matrix
157181# TODO Check - the eigenvalue distribution looks funky
158182# TODO The appropriate matrix size should be calculated from a and one matrix dimension
183+ """
184+ rand(d::GaussianLaguerre, dims::Tuple)
185+
186+ Generate a random matrix sampled from the Gaussian Laguerre ensemble (also known as the Wishart ensemble)
187+ with parameters defined in `d` and dimensions given by `dims`.
188+
189+ The Dyson index `β` is restricted to `β = 1,2` or `4`, for real, complex, and quaternionic fields, respectively.
190+ """
159191function rand (d:: GaussianLaguerre , dims:: Dim2 )
160192 n = 2.0 * a/ d. beta
161193 if d. beta == 1 # real
@@ -172,15 +204,23 @@ function rand(d::GaussianLaguerre, dims::Dim2)
172204 return (A * A' ) / dims[1 ]
173205end
174206
175- # Generates a NxN bidiagonal Wishart matrix
207+ """
208+ bidrand(d::GaussianLaguerre, n::Int)
209+
210+ Generate an `n × n` bidiagonal matrix sampled from the Gaussian Laguerre ensemble (also known as the Wishart ensemble).
211+ """
176212function bidrand (d:: GaussianLaguerre , m:: Integer )
177213 if d. a <= d. beta* (m- 1 )/ 2.0
178214 error (" Given your choice of m and beta, a must be at least $(d. beta* (m- 1 )/ 2.0 ) (You said a = $(d. a) )" )
179215 end
180216 Bidiagonal ([chi (2 * d. a- i* d. beta) for i= 0 : m- 1 ], [chi (d. beta* i) for i= m- 1 : - 1 : 1 ], true )
181217end
182218
183- # Generates a NxN tridiagonal Wishart matrix
219+ """
220+ tridrand(d::GaussianLaguerre, n::Int)
221+
222+ Generate an `n × n` tridiagonal matrix sampled from the Gaussian Laguerre ensemble (also known as the Wishart ensemble).
223+ """
184224function tridrand (d:: GaussianLaguerre , m:: Integer )
185225 B = bidrand (d, m)
186226 L = B * B'
@@ -218,14 +258,35 @@ end
218258# Jacobi ensemble #
219259# ##################
220260
221- # Generates a NxN self-dual MANOVA matrix
261+ """
262+ GaussianJacobi(β::Real, a::Real, a::Real)` <: ContinuousMatrixDistribution
263+
264+ Represents a Gaussian-Jacobi ensemble with Dyson index `β`, while
265+ `a`and `b` are parameters used to weight the joint probability density function of the ensemble.
266+
267+ `MANOVA(β, a, b)` is a synonym.
268+
269+ ## Fields
270+ - `beta`: Dyson index
271+ - `a`: Parameter used for shaping the joint probability density function near `λ = 0`
272+ - `b`: Parameter used for shaping the joint probability density function near `λ = 1`
273+
274+ ## References:
275+ - Edelman and Rao, 2005
276+ """
222277mutable struct GaussianJacobi <: ContinuousMatrixDistribution
223278 beta:: Real
224279 a:: Real
225280 b:: Real
226281end
227282const MANOVA = GaussianJacobi
228283
284+ """
285+ rand(d::GaussianJacobi, n::Int)
286+
287+ Generate an `n × n` random matrix sampled from the Gaussian-Jacobi ensemble (also known as the MANOVA ensemble)
288+ with parameters defined in `d`.
289+ """
229290function rand (d:: GaussianJacobi , m:: Integer )
230291 w1 = Wishart (m, int (2.0 * d. a/ d. beta), d. beta)
231292 w2 = Wishart (m, int (2.0 * d. b/ d. beta), d. beta)
0 commit comments