Keywords: Largenumbers.svg valid svg gnuplot en An illustration of the w law of large numbers similar to File LLN_Die_Rolls gif but using the svg format instead of gif This uses different data from that and hence it looks different Source code is in the section below The code is under the same license as the work itself own NYKevin 23 04 31 January 2010 UTC File LLN_Die_Rolls gif Probability theory Source code Note that you will need to insert some paths I've tried to make it obvious where to do so This code is all in the public domain the cc0 waiver applies to it The code in Java which generated the data <source lang java >import java io ; public class Main public static void main String args PrintStream output null; try output new PrintStream ;//FIXME Insert a suitable path in the quote marks catch FileNotFoundException e throw new RuntimeException e ; //int diceValues 0 0 0 0 0 0 ;//this variable may be uncommented and used for debugging double average 0; double total 0; output println count average ;//makes a header for the data; may be safely removed Random rnd new Random 4124484382302655524l ; //seed selected by trial and error for int i 1;i< 1000;i++ int rand rnd nextInt 6 ;//now holds a random int from 0 to 5 //diceValuesrand++;//uncomment for debugging rand++;//convert to 1-indexed total+ rand; average total/i; output println i+ + average ; //System out println average ; </source> The gnuplot code <source lang gnuplot > set terminal svg set output OUTPUT PATH HERE set title average dice value against number of rolls set xlabel trials set ylabel mean value plot 1 6 PATH FROM JAVA CODE HERE title average with lines 3 5 title y 3 5 with lines it is recommended that you copy and paste this code into a plt file and run it in batch mode If you must run this interactively be sure to type exit or D control-D at the end or gnuplot will leave off the </svg> closing tag </source> cc-zero ImageNote 1 59 223 75 70 600 480 2 On the left random fluctuations are evident ImageNoteEnd 1 ImageNote 2 183 219 192 46 600 480 2 Here the average begins to level out around 3 5 ImageNoteEnd 2 |