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

RE: [ns] Problem with the generation of random numbers




Thanks for helping me.

I modified in fact expoo.cc adding some functionalities. I added a function CalcDTX(A,P). 

This is my function next_interval() after modification :

double EXPOO_Traffic::next_interval(int& size)
{
	double t = interval_;
	if (rem_ == 0) {
		rem_ = int(burstlen_.value() + .5);    <-- (1)
		CalcDTX(A,P);            		  <-- (2)
		/* compute number of packets in next burst */
		/* make sure we got at least 1 */
		if (rem_ == 0)
			rem_ = 1;
		/* start of an idle period, compute idle time */
		t += Offtime_.value();
	}	
	rem_--;
	size = size_;
	return(t);
}

This is CalcDTX() : 

void EXPOO_Traffic::CalcDTX(int AA[sizeAP], int PP[sizeAP])
{
	double pa[5] = {0.271, 0.131, 0.000225, 0.00203, 0.00270};
	double pp[5] = {0.164, 0.106, 0.0881, 0.0624, 0.0563};
	double pia[3] = {0.426, 0.481, 0.0936};
	double pip[3] = {0.676, 0.323, 0.00148};
	double lamdaa[3] = {0.0802, 0.00976, 0.00324};
	double lamdap[3] = {0.121, 0.0275, 0.00126};
	double Qa[8], Qp[8];
	int Tstate;
	int i;
	double rand_val;
        	cumsum(Qa, pa, pia);
	cumsum(Qp, pp, pip);
	
	for (i=0; i<sizeAP; i++)
	{
		rand_val = Random::uniform();
		Tstate = NumberLessThen(Qa, rand_val) + 1;
		if (Tstate <= 5)
		{
			AA[i] = Tstate;
		}
		else
		{			
                        	rand_val = Random::uniform();
			AA[i] = 6 + (int)(-log(rand_val) / lamdaa[Tstate-5]);
		}
		rand_val = Random::uniform();
		Tstate = NumberLessThen(Qp, rand_val) + 1;
		if (Tstate <= 5)
		{
			PP[i] = Tstate;
		}
		else
		{
			rand_val = Random::uniform();
			PP[i] = 6 + (int)(-log(rand_val) / lamdap[Tstate-5]);
		}
	}
}

It's calling other functions...

(1) must give me a exponential value

and (2) give me a 2 vectors of size AP, with random values, with some formulas.

The main problem is by changing the order of (1) and (2), 

(2) : CalcDTX(A,P);            			
(1) : rem_ = int(burstlen_.value() + .5);    

The exponential value depend on the numbers of random values generated before. 

Is it normal ? I was not expecting a correlation between this 2 operations.

Thanks in advance, 

Karim.

NB: The Floating Point Exception was not correlated to this probelm, I solved it.

Karim El-Khazen
Email : [email protected] 
Website : http://www.directmoving.com 
�
-----------------------------------------------------------------
Karim C. El-Khazen� [email protected] http://www.elkhazen.com
MS in Electrical & Computer Engineering, Georgia Tech, Atlanta, USA 
Ericsson Radio Systems AB, S-164 80 Stockholm SWEDEN
-----------------------------------------------------------------


-----Original Message-----
From: Haobo Yu [mailto:[email protected]]
Sent: Thursday, August 24, 2000 4:06 AM
To: Karim El-Khazen (ERA)
Cc: [email protected]
Subject: Re: [ns] Problem with the generation of random numbers


It'll greatly help if you can provide some example scripts. I calculated
100 exponential values then 200 exponential ones, and the first 100 of the
second run are identical to those in the first run.

On Tue, 15 Aug 2000, Karim El-Khazen (ERA) wrote:

> Hi everybody,
>  
> I'm having a problem with the generation of random numbers. 
>  
> 1 ) I'm computing N random variables with " Random::uniform() " THEN an exponential random variable using " ExponentialRandomVariable ". I get coherent results which seem correct. If I run this simulation plenty of time, I always get the same values, since I'm not changing any initial values.
> I tried after to change the number N of random uniform variables, the exponential value changed. It shouldn't, no ?
> These parameters are not correlated at all (except in the random generator?!).
>  
> 2) Then I tried to reverse the order of these generations. For N=100, it gives me a result. For N=50, I get a "Floating Point Exception (core dumped)" !!!
>  
> Is there anybody who can help me solve this problem ?
>  
> Thanks in advance, Karim.
> 
> 
>  
> Karim El-Khazen
> Email : [email protected] 
> Website : http://www.directmoving.com 
> 
> -----------------------------------------------------------------
> Karim C. El-Khazen  [email protected] http://www.elkhazen.com 
> MS in Electrical & Computer Engineering, Georgia Tech, Atlanta, USA
> Ericsson Radio Systems AB, S-164 80 Stockholm SWEDEN
> -----------------------------------------------------------------
>