Description

The MultiWeightGen Generator allows multiple values to be weighted to determine how often each value is generated. You can enter a constant value for the percentage or reference another value for the percentage. 


For example, if a valueList contained (economy, midsize, and luxury) and the percentList contained (50, 35, and 15): 

  • economy would be generated 50% of the time
  • midsize would be generated 35% of the time
  • luxury would be generated 15% of the time


Note: It is best to have the percentages add up to 100%; however, the Generator has been designed to allow percentages greater than 100% in rare cases when needed. 


In This Article


Training Video

Please see the following video for a quick tutorial: 


Generator Parameters

The following parameters may be configured for the MultiWeightGen Generator. Items with an asterisk* are required. 

  • valueList - Enter the desired values into the value list. Press ENTER to save each entry. If you need to change your entries, use the navigation commands on the right. Each value entered will be associated to the value in the percentList in the same position.

  • percentList - Enter the desired percentages or add a reference for the associated values in the valueList into the list. Percentages MUST be integers. Press ENTER to save each entry. If you need to change your entries, use the navigation commands on the right.

  • seed - Using the seed will ensure that the same random data is generated each time data is generated.

  • exactPercentage* - When the exactPercentage is true, the random distribution matches exactly the percentages specified. When exactPercentage is false, the random distribution is determined in real time and may not match exact percentages. The larger the distribution, the more exact the percentage will be. 


Example 1 - Generate Rental Vehicle Type by Percentage

If the Generator has not already been assigned, you must assign it to the Attribute. Please see this page for more details: How do I assign a Generator to a single Attribute?


Generator Configuration

  • valueList Parametereconomy, midsize, luxury
  • percentList Parameter - Enter each value that will be associated with the value in the valueList Parameter. For this example, we will use these values: 
    • economy = 50%
    • midsize = 35%
    • luxury = 15%
  • seed - no value
  • exactPercentage - True (ensures the percentage for each value will be matched precisely)



Sample Output

The data will appear similar to what is shown below. If 100 records are generated, the following percentages exist in the output data (when exactPercentage parameter is 'True'): 

  • economy (50 records) = 50%
  • midsize (35 records) = 35%
  • luxury (15 records) = 15%



Example 2  - Generate Loan Type (By Percentage) and Interest Rate

A tester wants to generate different loan types by percentage. They want to generate the following loan types: Personal, Mortgage, or Auto



You can easily do this with the MultiWeightGen. 

  • Personal = 50%
  • Mortgage = 30%
  • Auto = 20%


You can also generate the loan interest rate based on the loan type by using the SwitchGen. A ListGen contains each possible interest rate for a specific loan type. 

  • Personal = 5%, 10%, 15%
  • Mortgage = 3%, 4%, 5%
  • Auto = 6%, 7%, 8%



Note: You could reference the ListGen generators directly in the percentList parameter of the MultiWeightGen to only generate the percentage value. The above approach is used so that both appear in the generated output and match.

The generated output would appear as shown below:


Additional Information

Here is another linked generator example: LInked MultiWeightGen Design Pattern.