Statistical Parameters

 

As already stated, JTR 5 allows you to define runners’ parameters whose values are generated at runtime according to well-known statistical functions. Let’s now see how it is possible to use this new feature.


Step 1: specify the statistical-functions factory

The very first step is about adding to the factories element a new factory sub-element right as follows:


<factory key="ITestStatFunctions" fqn="jtr.lang.functions.impl.DefaultStatFunctionsFactory" />


Step 2: use the param element with attribute type equal to statistical

Let’s suppose your runner Foo has a property x of type java.lang.Double and that you want it to be assigned to a value generated according to the Gaussian distribution. That’s all you have to do:


<param name="x" type="statistical" value="Gaussian(5.5,1.0,8)"/>


that is, use a param element with type statistical and value Gaussian(mean, stdDeviation[, seed]). The third parameter is within square brackets since it is optional. If provided it represents the seed used by the internal pseudo-random number generator.


Built-in statistical functions

JTR 5 comes with six built-in statistical functions, namely:

  1. -Exponential(mean[, seed])

  2. -Gaussian(mean, stdDeviation [, seed])

  3. -Poissonian(mean[, seed])

  4. -UniformDouble(min, max[, seed])

  5. -UniformInt(min, max[, seed])

  6. -UniformLong(min, max[, seed])


Adding your own functions

JTR 5 allows you to add your own functions too. All you need to do is:

- implement your own function(s) implementing the jtr.lang.functions.IStatFunction interface

  1. -extend the jtr.lang.functions.impl.DefaultStatFunctionsFactory class

  2. -specify your own new factory class in your jtr.xml

  3. -apply “Step 2” specifying your own function invocation



Next step: working with scripted parameters