Using Random Rule and Sampling Rule Steps

Last Updated: 07/26/2016 Introduced in Verision: 2.0

The Random Rule and Sampling Rule components provide tests for probability in a flow. Within certain boundaries, both components will randomly return one of two outcomes “True” or “False.” This randomness can be weighted by configuring the percentage of times that the outcome will be true, on average. To guarantee the ratio of “True” to “False” outcomes, the Sampling Rule offers an additional option for configuring the sample size. The Random Rule and Sampling Rule components can be found in the Flow Designer in the Toolbox panel, under the category Data > Rules.

Example

Our example flow will randomly choose to follow one of three paths. 50% of the time, on average, it will follow the path to send a Customer Satisfaction survey. If our flow does not follow the path to send a Customer Satisfaction survey, it will randomly choose to either send a thank you email, or send a thank you email containing a coupon, 50% of the time.
 
The sample size for this second choice is 10. This means that if our flow chooses to follow the path to send a thank you email containing a coupon five times, it will not choose that path again until it has chosen both paths a total of 10 times. The same holds true with the options reversed.
 
It’s easier to visualize how probabilities work in practice. Here is the flow that contains the random and sampling rule components:
 flow
 
 
 
These are the three paths described earlier. These paths will: send a customer satisfaction survey, send a thank you email, or send a thank you email containing a coupon.

The first probability test whether our flow will send the survey or emails  is determined by the Random Rule component. It can be found in the Toolbox panel, under the heading Data > Rules.

locateSteps

 

The second probability test, whether our flow will send an email with a coupon or not, uses the Sampling Rule component. It can be found in the Toolbox panel, also under the heading Data > Rules.

For the paths, connect Random Rule 1’s “True” outcome to the path that sends the survey, and the “False” outcome to Sampling Rule 1. Sampling Rule 1’s “True” outcome will be mapped to the path that sends the plain thank you email, and its “False” outcome will be mapped to the path that sends a thank you email containing a coupon.
 

Next, configure Random Rule 1 to choose the “True” outcome 50% of the time. Click on this step, and go to the Properties panel, under the section Inputs > PercentTrue.

Because PercentTrue is an input, we could dynamically determine the probability of a truthful outcome by giving it a dynamic mapping. We only need our outcome to be truthful 50% of the time, all the time, so we will give this input the Mapping type Constant and a Value of “50.”

randomRule1Eq50

 

Next, configure Sampling Rule 1. Just like Random Rule 1, Sampling Rule 1 should return a truthful outcome 50% of the time, so map its input to a Constant and a Value of “50.”

We also want to guarantee that 50% of the outcomes will be truthful when Sampling Rule 1 is tested 10 times. This can be configured under the section Inputs > sampleKey. We want our sample size to be a constant value of 10, so give sampleKey a Mapping type of Constant, and a Value of “10.”
 semplingRuleConf
 

This completes our flow. It’s now ready to be saved and tested.

In our first debugger session, Random Rule 1 returned the outcome “False,” and therefore the customer satisfaction survey was not sent.
 
 

In our second debugger session, Random Rule 1 returned the outcome “True,” which directed our flow to Sampling Rule 1. Sampling Rule 1 returned the outcome “True,” therefore a thank you email was sent.

debugResultFirstFalse

For the next ten times that Random Rule 1 has a truthful outcome, Sampling Rule 1 will be given the option to randomly return either a “True” or “False” outcome. By the tenth time, however, it will have chosen both outcomes exactly five times.

debugResultTrue

 
 
 

Additional Resources