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

Re: [ns] How to generate a random number



Here's an example :

set n [new RandomVariable/Normal]
$n set max_ $max
$n set min_ $min

for {set i 1} {$i < 11} {incr i} {
	puts "n = [$n value]"
}

apart from possible typos this should print ten random values, according to a 
normal distribution. There are other distributions available. grep for them. And 
do search the mailing list archives, you will find more examples.
	
>From: "Liu Qiang" <[email protected]>
>To: <[email protected]>
>Subject: [ns] How to generate a random number
>Date: Thu, 14 Sep 2000 11:21:00 +0800
>MIME-Version: 1.0
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
>Content-Transfer-Encoding: 8bit
>X-MIME-Autoconverted: from base64 to 8bit by zephyr.isi.edu id UAA19417
>
>hi all,
>
>    I want to write a simple tcl script in ns2 and need a random number 
generator. How can I generate a random number with the tcl script? Expect the 
reply.
>
>    Regards
>
>Qiang Liu
>
>Institute of Computing Technology,
>Chinese Academy of Sciences

Tarik