Page by [Theo Verelst] Not intended as another tcl or tk gem, but quite seriously, lets make tcl throw dice, and see where we get. The function most easy to use for 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 die 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 die 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 let's draw the results to scale, rounding to whole numbers in a little graph: canvas .c pack .c -expand y -fill both for {set i 0} {$i < [llength $to]} {incr i} { .c create line $i 100 $i [expr 100-[lindex $to $i]] -tag g1 } [http://82.168.209.239/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 let's 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. I'll make a new page on [Gaussian Distribution]. Also see [Throwing Two Dice]. ---- What is the relevance of this subject? First it's fun to do these things in tcl, it's 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. ---- [TP] Not so random coin toss: http://www.npr.org/features/feature.php?wfId=1697475 The audio available on this page is worth a listen. ---- [FW]: There is such thing as a 100-sided (d100) die. [http://www.doordice.com/Departments/ProductDetails.cfm?Product_UID=PA39XH0R] ---- [[ [Category Mathematics] ]]