Page by [Theo Verelst] Not intended as another tcl or tk gem, but quite seriously, lets make tcl throw dices, and see where we get. The function to use as most easy way to do this, but unfortunately with predictable results when we know the seed, is of course a subfunction of [expr] called [rand] . To see how pure our dice is, we simply throw it many times and see how often the sides come up, or to make it a bit more interesting, we take a dice which supposedly has a hundred sides it can roll on, and see how many times each side comes up, and draw a graph of the result. set to {}; for {set j 0} {$j < 100} {incr j} { set o 0; for {set i 0} {$i < 100} {incr i} { set o [expr $o+rand()] }; lappend to $o } a hundred times a hundred throws on a row, with the averages stored in a list in variable to. Now lets draw the results to scale, rounded to whole numbers in a little graph: canvas .c pack .c -expand y -fill both for {set i 0} {$i < [llength $to]} {incr i} { $mc create line $i 100 $i [expr 100-[lindex $to $i]] -tag g1 } [http://195.241.128.75/Wiki/throwdice1.jpg] For electronicists probably a perfect enough little distribution graph, no unlikely things like a hundred events with expectation value of 0.5 adding up to very far from 50, no clear patterns, clearly a near white noise source. Now lets analyze the distribution of the averages, by making a (sampled) distribution graph, which the values in this graph are limited to whole numbers, and the relative frequency of all occuring results plotted, to see if we get near the theoretical 'normal' or 'gaussian' distribution. ---- What is the relevance of this subject? First its fun to do this things in tcl, its a whole lot of work in other environments, and not a quarter of the fun. Main line scientific applications are: * quantum physics theory * electronical circuit analysis * quantized signal analysis * in the physicists sense but less elevated: all measurement based data bein processed * event systems, where usually the distribution of events has well defines statistical sides to it * System analysis, where a lot of crap can be prevented by getting you statistics right.