Weighted Distribution of Virtual Users

Document created by Dave Murphy Employee on Jul 20, 2017
Version 1Show Document
  • View in full screen mode

You may have a need during testing for your users to make a decision on which path they are going to follow. You have two options when implementing this logic, both of which require the use of JavaScript.

 

Below are two example scripts which can be used to implement a weighted distribution. In both examples the weights have been defined as:

* 25% of all users follow path A.

* 25% of all users follow path B.

* 50% of all users follow path C.

 

In this case, the various paths define the number of repeats a particular group is going to execute, as defined in the __ATCrepeatCount property.

 

Example 1:

function generateRandomNumber(lowerExtreme, upperExtreme) {

   return Math.floor(Math.random() * (upperExtreme - lowerExtreme) + lowerExtreme);

}

 

var randomNumber = generateRandomNumber(0,10000);

if(randomNumber <= 2500) {

   // Path A

   $prop.set("MessageClip","__ATCrepeatCount",1);

} else if(randomNumber > 2500 && randomNumber <= 5000) {

   // Path B

   $prop.set("MessageClip","__ATCrepeatCount",100);

} else {

   // Path C

   $prop.set("MessageClip","__ATCrepeatCount",10);

}

 

The above example uses a random number to determine which weighted path the virtual user should take. This gives you a very granular level of control over your percentage distribution, however it is subject to randomization.

 

Example 2:

var vuNumber = $context.currentTrack.systemPropertyList.getPropertyValue( "VUNumber");

 

if(vuNumber % 4 === 0) {

   // Path A

   $prop.set("MessageClip","__ATCrepeatCount",1);

} else if(vuNumber % 2 === 0) {

   // Path B

   $prop.set("MessageClip","__ATCrepeatCount",100);

} else {

   // Path C

   $prop.set("MessageClip","__ATCrepeatCount",10);

}

 

In this example, we're using the Virtual User number to determine our weighted path. This method is not subject to randomization, and the users will follow the same path every time this composition is played back. It does come with some disadvantages however. Using this method, a particular virtual user is locked into a path when it is created, and that path will not change on subsequent repeats of the track (i.e. Every time virtual user #10 repeats, it will follow the same path it will never deviate into the other paths). Additionally, the granularity of your distribution is slightly more limited, and can be difficult to calculate.

Attachments

    Outcomes