[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: random number generator



you can use any of the following :
    set r [expr rand()*1000]     # where 1000 is the range
    set r [ns-random 0]

Good luck

Fusun Inanc wrote:

> Hi all,
>
> I need to generate random numbers in my simulation.. I used following commands:
>
> set random1 [new RandomVariable/Uniform]
> $random1 set min_ 0.0
> $random1 set max_ 1.0
> set start1 [$random1 value]
>
> $ns at $start1 "$ftp1 start"
> puts "start1 = $start1"
>
> for each ftp nodes. But when I run the simulation it generates random numbers
> for each nodes but when I run it again it finds the same values ...
>
> For example...
>
> fusun%poptop [19] ns as.tcl
> start1 = 2.189592e-01
> start2 = 4.704462e-02
> start3 = 6.788647e-01
> start4 = 6.792964e-01
> start5 = 9.346929e-01
> fusun%poptop [20] ns as.tcl
> start1 = 2.189592e-01
> start2 = 4.704462e-02
> start3 = 6.788647e-01
> start4 = 6.792964e-01
> start5 = 9.346929e-01
> fusun%poptop [21]
>
> What I want is every time when I run the simulation It has to find different
> numbers then previous ones.
>
> Thanks in advance..
>
> Fusun Inanc