New in Wolfram
Mathematica
8: Parametric Probability Distributions
◄
previous
|
next
►
Core Algorithms
Distribution of Eigenvalues of a Symmetric Random Matrix
Fit a
WignerSemicircleDistribution
into eigenvalues of a symmetric random matrix generated using a symmetric continuous parametric distribution.
In[1]:=
X
RandomSymmetricMatrix[dist_, n_] := Module[{mat = RandomVariate[dist, {n, n}]}, UpperTriangularize[mat, 1] + Transpose[UpperTriangularize[mat]] ]
In[2]:=
X
dists = {NormalDistribution[], StudentTDistribution[4], LaplaceDistribution[0, 1], WignerSemicircleDistribution[3]}; ev = Eigenvalues[RandomSymmetricMatrix[#, 10^3]] & /@ dists; edist = EstimatedDistribution[#, WignerSemicircleDistribution[r]] & /@ ev;
In[3]:=
X
h[dist_, data_, i_] := Histogram[data, 20, "PDF", ChartStyle -> (ColorData["Gradients"][[RandomInteger[{1, 51} ] ]]), BaseStyle -> {FontFamily -> "Verdana"}, PlotLabel -> dists[[i]], PlotRange -> {0, 1.5 PDF[dist, 0]}, ImageSize -> 280, Epilog -> Inset[Framed[ Style[Grid[{{"Estimated Distribution:"}, {dist}}], 10], RoundingRadius -> 10, FrameStyle -> GrayLevel@0.3, Background -> LightOrange], {Right, 1.45 PDF[dist, 0]}, {Right, Top}]] distPlot[dist_, data_] := Plot[PDF[dist, x], {x, Min[data], Max[data]}, PlotStyle -> {Thick, Black}]
In[4]:=
X
Grid[Partition[ Table[Show[h[edist[[i]], ev[[i]], i], distPlot[edist[[i]], ev[[i]]]], {i, 4}], 2]]
Out[4]=