@@ -51,8 +51,8 @@ rand{β}(d::Type{Wigner{β}}, dims...) = rand(d(), dims...)
5151
5252function rand (d:: Wigner{1} , n:: Int )
5353 A = randn (n, n)
54- normalization = √ ( 2 * n )
55- return Symmetric ((A + A' ) / normalization)
54+ normalization = 1 / √ ( 2 n )
55+ return Symmetric ((A + A' ) / 2 * normalization)
5656end
5757
5858function rand (d:: Wigner{2} , n:: Int )
@@ -90,16 +90,19 @@ Unlike for `rand(Wigner{β}, n)`, which is restricted to β=1,2 or 4,
9090The β=∞ case is defined in Edelman, Persson and Sutton, 2012
9191"""
9292function tridrand {β} (d:: Wigner{β} , n:: Int )
93+ χ (df:: Real ) = rand (Distributions. Chi (df))
9394 if β≤ 0
94- throw (ValueError (" β = $β cannot be nonpositive" ))
95+ throw (ValueError (" β = $β cannot be nonpositive" ))
9596 elseif isinf (β)
96- return tridrand (Wigner{Inf }, n)
97+ return tridrand (Wigner{Inf }, n)
9798 else
98- Hd = randn (n)/√ (n)
99- He = [χ (β* i)/√ (2 * n) for i= n- 1 : - 1 : 1 ]
100- return SymTridiagonal (Hd, He)
99+ normalization = 1 / √ (2 n)
100+ Hd = rand (Distributions. Normal (0 ,2 ), n)./√ 2
101+ He = [χ (β* i)/√ 2 for i= n- 1 : - 1 : 1 ]
102+ return normalization * SymTridiagonal (Hd, He)
101103 end
102104end
105+
103106function tridrand {β} (d:: Wigner{β} , dims... )
104107 if length (dims)== 2 && dims[1 ] == dims[2 ]
105108 return rand (d, dims[1 ])
0 commit comments