ExponentialRandomVariable gives me two different values

20 views
Skip to first unread message

maede zolanvar

unread,
Oct 16, 2017, 12:55:29 PM10/16/17
to ns-3-users

I'm completely confused by random-variable-stream.h. I'm trying to print out the value of "OffTime" by the below code:


 Ptr<ExponentialRandomVariable> x = CreateObject<ExponentialRandomVariable> ();

 x->SetAttribute ("Mean", DoubleValue (0.1));

 std::stringstream value ;

 value <<"ns3::ConstantRandomVariable[Constant=" << x->GetValue ()<<"]";

 onoff.SetAttribute("OffTime",StringValue(value.str()));

 

 NS_LOG_UNCOND("off time:" << value.str());

 NS_LOG_UNCOND("off time:" << x->GetValue());


But the print gives me 2 different values, while I have used the same value of "x" in "value". My output is this:


off time:ns3::ConstantRandomVariable[Constant=0.0422695]

off time:0.338839


Please help :(

Konstantinos

unread,
Oct 16, 2017, 2:05:33 PM10/16/17
to ns-3-users
Hi,

The results are as expected. The 'x' is a random variable and each time you call "GetValue()" a new one is generated.

Regards,
K
Reply all
Reply to author
Forward
Message has been deleted
0 new messages