3

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]]

Wignersemicircledistribution

My question is: how can I make an animated version of Wigner semicircle distribution as shown below?

image

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Zbigniew
  • 411
  • 1
  • 4
  • 12

2 Answers2

5

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.

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
  • 3
    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
  • 1
    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
2
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]]]]

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896