3
$\begingroup$

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

$\endgroup$
10
  • 1
    $\begingroup$ What is the question? Please elaborate. $\endgroup$ Commented Feb 23, 2015 at 6:11
  • $\begingroup$ @Yves Klett How to get this image in mathematica 10 $\endgroup$ Commented Feb 23, 2015 at 7:04
  • 2
    $\begingroup$ Please edit your question to reflect that. Also, if you show what you already tried, you might get more answers. $\endgroup$ Commented Feb 23, 2015 at 7:43
  • $\begingroup$ Ok, serious now, do you want to export gif? Have a loop with precalculated frames? Dynamic random frame? Interactive Manipualte? $\endgroup$ Commented Feb 23, 2015 at 8:41
  • 2
    $\begingroup$ 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] $\endgroup$ Commented Feb 23, 2015 at 8:42

2 Answers 2

2
$\begingroup$
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

$\endgroup$
5
$\begingroup$

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.

$\endgroup$
2
  • 3
    $\begingroup$ 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. $\endgroup$ Commented Feb 23, 2015 at 17:07
  • 1
    $\begingroup$ 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. $\endgroup$ Commented Feb 23, 2015 at 17:14

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.