jmeter and random number distribution - jmeter

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.

Related

Generate dynamic random variable in combination of alphabets and numbers for POST

I want to generate a dynamic random variable like ASDF123 during Post request and it should range from 7 digit to 10 digit and it should be unique everytime(if in case 500 threads). This field is required to generate order numbers. I'm new to Jmeter so not much idea.
My Scenarios is like this: .> I have to generate a variable in combination of alphabets and letters(like this ->ASDF12345) for post then need to provide same variable to get to retrieve the same order for each thread. It is working fine if I generate random variable ie. minimum 1000 to max:9999 and passing same to post and get. But the req is that the order no. can be alphabets & numeric/numeric/alphabet. Please suggest how to proceed for the same. And yes everytime it should be unique.
You can use Functions as:
RandomString - First parameter how many characters (10 in your case) and second parameter choose your combination of alphabets and numbers:
${__RandomString(10,abcdefg1234567890)}
Use Random if alphabets can be constant, and then add a number with 7-10 digits:
ASF${__Random(1000000,1000000000)}
Or use JSR223 element to use Random in your programming language as Java/Groovy.
You can try this:
${__javaScript(Math.random().toString(36).toUpperCase().substring(16))}
In jmeter it must looks like this:

Omnet++ uniform random number generation

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.

Spark RDD into Matrix

I have an RDD like:
(A,AA,1)
(A,BB,0)
(A,CC,0)
(B,AA,2)
(B,BB,1)
(B,CC,4)
and I want to convert it into the following RRD:
([1,0,0],[2,1,4])
the order is important for me since the main propose is using RowMatrix to convert the second RDD to a matrix.
Your need to be careful with the wording, when you ask for a Matrix, do you mean something like the spark.mllib.matrix ? If so, you will need to follow very specific instructions to create one. However, it seems to me that your problem can be solved in a much easier way. Just using zipWithIndex with groupBy
//Here is how I see it
val test = sc.parallelize(Array(("A","AA",1),("A","BB",0),("A","CC",0),("B","AA",2),("B","BB",1),("B","CC",4))).zipWithIndex
val grouptest = test.groupBy(_._1._1).map(x=>(Vectors.dense(x._2.map(y=>(y._2,y._1._3)).toArray.sortBy(_._1).map(z=>z._2.toDouble))))
In your example, you seem to want the result as a vector? So I used spark's Vector (which by the way, only allows Doubles).
Result looks like:
[1.0,0.0,0.0]
[2.0,1.0,4.0]

healpy synfast: how to define the random seed

I'm using healpy.synfast to create maps, but it seems that healpy does not have the "iseed" function (as in here: http://healpix.jpl.nasa.gov/html/facilitiesnode14.htm) which let me define the random seed to be used for the generation of alms from the power spectrum.
Could anyone tell me how to achieve the "iseed" function in healpy? Thanks!
healpy internally uses np.random.standard_normal to generate the real and imaginary components of the alms, see sphtfunc.py.
Therefore you can use the numpy.random.seed function to set the seed, as:
numpy.random.seed(1234)
before running synfast.

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