Omnet++ uniform random number generation - omnet++

When I assign the result of a intuniform(a,b) function call to a number, it always results in the same value. For example:
val = intuniform(0,100);
val is always 44 for every run.
How can I manage that?

Generating the same values by OMNeT++ RNG is intentional behaviour. In order to manage generated sequence one can change seed or just add a repetition in omnetpp.ini.

Related

how to validate a random variable in jmeter, if it is unique or not for requests

Here I want to generate a random 9 digit number, I have achieved it using a config element->Random Variable.
Now I need to check if that number is unique or not, so for that, I have used If the controller and passed a condition checking the previous response message is true or false, if the output is false, then it will again generate a Random variable and this time a newly generated will be passed onto it.
But till how many times I will check this using If controller, so needs an alternative solution for the same.
Below is the hierarchy of my test plan:
Random variable
Sampler HTTP Request(Here random variable is passed)
If Controller(Condition: ${JMeterThread.last_sample_ok}==false)
Random Variable generated again
Sampler HTTP Request(Here random variable is passed)
If you need to generate a random number there is no need to "validate" it
If you need to generate an unique number the number has to be sequential
You can generate sequential numbers using Counter configuration element which should be set up like this:
once done you can refer the generated value as ${number} where required
More information:
What is mathematical difference between "random" and "unique"?
How to Use a Counter in a JMeter Test

jmeter and random number distribution

I would like to use jmeter, but I need to get it to generate random numbers using a gaussian distribution. Any idea on how to achieve that? All I can see is a Minimum Value and a Maximum Value for the random variable config element
Thanks
Use JSR223 Pre or Post processor depend on your requirement to generate random using Gaussian distribution.
Below is the code:-
rnd = new Random()
result = (1..1000).inject([]) { r, i -> r << rnd.nextGaussian() }
log.info ">>>>>>>>>>>>>>>>>"+result
Below is the reference from where I have got this.
https://rosettacode.org/wiki/Random_numbers#Groovy
One more reference, for Java and many others:-
http://www.cs.yale.edu/homes/spielman/ECC/gauss.html
Hope this helps.

Random values in tensorflow

I want to generate random numbers within an activation function such that every time the activation function is called a random number is generated. I tried with random.uniform and with tf.random_uniform but it only generates a single random value when it's compiled and it doesn't change anymore. How can I make it update every time?
Funny fact:
When I create a variable using tf.Variable(random.uniform(1,2)) every time the function it's called the value is slightly larger, for instance:
1.22069513798
1.22072458267
1.22075247765
1.22077202797
Edit:
The function is very simple
Function:
def activation(tensor):
alpha = tf.Variable(random.uniform(1,2))
return alpha*tensor,alpha
I will omit all the lines in the neural network, but I simply call it as:
act,alpha = activation(dense_layer+bias)
I later get the value by simply:
[ts,c,alph]=sess.run([train_step,cost,alpha], feed_dict={xi: x_raw, yi: y_raw})
Thanks
Hard to tell without source code, but maybe you are initializing your variable with that random value and reusing same value?
Another possibility:

Different parameters value in .ini file for different runs

How can I have different parameters value defined in .ini file for each repeat in omnet using cmdenv? I have repeat value as 4 and trying to have different value of accidentStart and accidentDuration.
You can't. And shouldn't. The whole point of repetition is that all parameters have the same value, just the RNGs are seeded differently. So you get a different sample of the same distribution for every result value.
What you're looking for are iteration variables.
Something like this:
**.accidentStart = ${100, 200, 350}s
This will generate 3 runs without repetition, and 12 runs with repeat=4.
and if you add
**.accidentDuration = ${duration=300, 450, 600..1800 step 600}s
this will multiply the number of runs by another factor of 5.
By default, iteration variables produce a Cartesian product of their respective assigned sets of values. But there are ways to change this, consult the manual for how.

Generate random number in vdm++

Does anyone know how to generate a random number in vdm++? The math library doesn't work for me.
You should be able to use the random generator in VDM (Both in VDMTools and Overture).
In Overture the argument must be larger than 0 and the seed must be set, which it is by default. Remember to include the standard MATH lib by selecting the project in the explorer and New->Add VDM Library and selecting MATH.
It can be called like this: MATH.rand(100) which will return a number between 0 and 100.
The seed can be changed through MATH.srand(5) it returns the seed set.

Resources