From: mwbuda@... Date: 2006-01-25T00:43:38+09:00 Subject: Re: problems with standard rand functions Timothy Goddard wrote: > # Start Script > > total = Hash.new(0) > > 1000000.times do > total[(rand * 10).to_i] += 1 > end > > 10.times do |t| > puts "#{t}0% - #{t + 1}0%: #{total[t] / 10000}%" > end > > # End Script > > > # Start Output > > 00% - 10%: 10.0151% > 10% - 20%: 10.009% > 20% - 30%: 10.0326% > 30% - 40%: 9.9543% > 40% - 50%: 10.0381% > 50% - 60%: 9.9985% > 60% - 70%: 9.963% > 70% - 80%: 9.97% > 80% - 90%: 9.997% > 90% - 100%: 10.0224% > > # End Output > > As you can see, there does not appear to be any simple skew at work > here. If you post your code, we may be able to identify the source of > any bias. whoops, im an idiot! i forgot to clear out the array the generated numbers were stuck in before perfroming a sort function, the result being that high values from previous rolls werent tossed out. thanks anyway