Class | AppMath::Ran |
In: |
random.rb
|
Parent: | Object |
Class of random generators. The real numbers delivered by different random generators are intended to be statistically independent. Each random generator has its own interval within which the output values are uniformly distributed.
iv | [R] |
The arguments have to determine an interval in which the random values lie. This is named @iv. If there is no argument we have @iv = [0,1]. If there is one argument, it has to be an instance of Iv and then becomes @iv. If there are two arguments they need to be convertible to R and then become the boundaries of @iv.
# File random.rb, line 35 35: def initialize(*arg) 36: n = arg.size 37: case n 38: when 0 39: @iv = Iv.new(0,1) 40: when 1 41: a0 = arg[0] 42: fail "argument must be an Iv" unless a0.class == Iv 43: @iv = a0 44: when 2 45: a0 = arg[0]; a1 = arg[1] 46: @iv = Iv.new(a0,a1) 47: else 48: fail "0,1,or 2 arguments needed, not #{n}" 49: end 50: x = R.ran(@@seed) 51: i = (@@swing * x).to_i 52: @local_seed = i 53: @@seed += 1 54: end