# How can I make an animated demonstration of the Wigner semicircle distribution?

With Mathematica 10, it's possible to draw the semicircle distribution of R. Wigner:

data = RandomVariate[WignerSemicircleDistribution[1, 3], 10^4];

Show[
Histogram[data, 20, "PDF"],
Plot[PDF[WignerSemicircleDistribution[1, 3], x], {x, -2, 4}, PlotStyle -> Thick]] My question is: how can I make an animated version of Wigner semicircle distribution as shown below? • What is the question? Please elaborate. – Yves Klett Feb 23 '15 at 6:11
• @Yves Klett How to get this image in mathematica 10 – Zbigniew Feb 23 '15 at 7:04
• Please edit your question to reflect that. Also, if you show what you already tried, you might get more answers. – Yves Klett Feb 23 '15 at 7:43
• Ok, serious now, do you want to export gif? Have a loop with precalculated frames? Dynamic random frame? Interactive Manipualte? – Kuba Feb 23 '15 at 8:41
• data := RandomVariate[WignerSemicircleDistribution[0, 1], 10^2]; Dynamic[ Show[ Histogram[data, 10, "PDF"], Plot[PDF[WignerSemicircleDistribution[0, 1], x], {x, -2, 4}, PlotStyle -> Thick] , PlotRange -> 2] , UpdateInterval -> .2] – Kuba Feb 23 '15 at 8:42

data := RandomVariate[WignerSemicircleDistribution[1, 3], 10^4];
Dynamic[Clock[{0, 5, 1}, 1]; Histogram[data, 20, "PDF", ChartStyle -> EdgeForm[White],
Axes -> False, PlotRange -> {{-4, 6}, {0, .25}}, ImageSize -> 400, Frame -> True,
Epilog->First[Plot[PDF[WignerSemicircleDistribution[1, 3], x], {x, -4, 6}, PlotStyle->Thick]]]] Kuba answered this question in a comment, but I think it needs to be recorded as a formal answer.

You can animate your static plot by wrapping it with Dynamic and supplying the option UpdateInterval.

data := RandomVariate[WignerSemicircleDistribution[1, 3], 10^4];
Dynamic[
Show[
Histogram[data, 20, "PDF"],
Plot[PDF[WignerSemicircleDistribution[1, 3], x], {x, -2, 4}, PlotStyle -> Thick]],
UpdateInterval -> .5]


The output will look exactly like the static plot you show in your question, but it will update every 0.5 seconds.

• Just a warning: Unfortunately, this crashes (in version 8) when you right-click on the animation. See my answer here where I work around this problem in the function makeAnimation. – Jens Feb 23 '15 at 17:07
• The crash bug has been fixed in version 10. But in version 8, don't use this, or the user will lose all their unsaved changes in the crash. – Jens Feb 23 '15 at 17:14