Keywords: Lawoflargenumbersanimation.gif en Simulation illustrating the Law of Large Numbers Each frame you flip a coin that is red on one side and blue on the other and put a dot in the corresponding column A pie chart notes the proportion of red and blue so far Notice that the proportion varies a lot at first but gradually approaches 50 Animation made in Mathematica--I'm happy to give you the source code if you want to improve the animation or for any other reason own Sbyrnes321 2010-02-26 Probability theory <pre> Source code written in Mathematica 6 0 by Steve Byrnes 2010 I release this code into the public domain SeedRandom1 NumBalls 500; Build list of point coordinates and radii BuildCoordListLeftX_ RightX_ BotY_ TopY_ Cols_ Rows_ FlattenTable i j j BotY TopY TopY - BotY / Rows - 1 i LeftX RightX RightX - LeftX / Cols - 1 1; BlueCoordsList BuildCoordList 15 85 15 4 75 5 24; RedCoordsList BuildCoordList1 15 1 85 15 4 75 5 24; radius 05; Draw borders lines Line 0 0 0 5 Line 1 0 1 5 Line 2 0 2 5 Line 0 0 2 0 ; Draw pie chart DrawPieCenterX_ CenterY_ Radius_ FracRed_ Red Disk CenterX CenterY Radius -FracRed \Pi FracRed \Pi Blue Disk CenterX CenterY Radius FracRed \Pi 2 \Pi - FracRed \Pi ; Randomly generate order that red and blue appear AppearOrder TableRandomInteger 0 1 i 1 NumBalls ; Calculate number of red and blue balls at any given time and their proportions NumAppearedtime_ Floortime; NumRedtime_ TotalAppearOrder1 ;; NumAppearedtime; NumBluetime_ NumAppearedtime - NumRedtime; FracRedtime_ NumRedtime/NumAppearedtime; Put everything together Video ; NumFrames 220; Forframe 1 frame < NumFrames frame++ t frame; ImageGraphicsList lines; Forpt 1 pt < NumBluet pt++ ImageGraphicsList AppendImageGraphicsList Blue DiskBlueCoordsListpt radius ; Forpt 1 pt < NumRedt pt++ ImageGraphicsList AppendImageGraphicsList Red DiskRedCoordsListpt radius ; ImageGraphicsList AppendImageGraphicsList DrawPie2 5 2 5 4 FracRedt; Video AppendVideo GraphicsImageGraphicsList ImageSize -> 100;; Slow the movie down at the beginning and end to make it easier to see Video Join TableVideo1 i 1 3 TableVideo2 i 1 3 TableVideo3 i 1 3 TableVideo4 i 1 3 TableVideo5 i 1 3 TableVideo6 i 1 2 TableVideo7 i 1 2 TableVideo8 i 1 2 TableVideo9 i 1 2 TableVideo10 i 1 2 Video11 ;; TableVideoNumFrames i 1 5 ; Export Export test gif Video DisplayDurations -> 14 AnimationRepititions -> Infinity </pre> Animated GIF |