MultiWeightGen Generator Example

The MultiWeightGen Generator allows one or more values to be weighted differently to determine the percentage of time each value is generated.

In this lesson, we will show two examples:

  • Example 1 – Rental Car Type by Percentage
  • Example 2 – Number Range by Percentage

Example 1: Rental Car Type by Percentage

For this example, the MultiWeightGen Generator will be used to generate a Rental Car Type based on the following percentage values.

  • 10% of the time, Luxury will be generated
  • 40% of the time, Midsize will be generated
  • 35% of the time, Economy will be generated
  • 25% of the time, Compact will be generated

Step 1: Use the input field for the valueList Parameter to enter a value and then press the Enter key.

For this example, four values have been entered:

  • Luxury
  • Midsize
  • Economy
  • Compact

Note: The buttons on the right can be used to move and edit an entry.

Step 2: For the percentList Parameter, enter the desired percentages for the associated values within the valueList Parameter. Percentages MUST be integers. Press the Enter key to save each entry.

For this example, four values have been entered:

  • 10
  • 40
  • 35
  • 25

Step 3: (Optional) A Seed value can be entered to ensure that the same random data is generated each time data is generated.

Step 4: (Optional) The exactPercentage Parameter defaults to “False.” When “False,” random distribution is determined in real-time and may not match exact percentages. The larger the distribution, the more precise the percentage will be.

When set to “True,” the random distribution matches exactly the percentages specified. For this example, it has been set to True.

Generated Output

The generated output is shown below:

Example 2: Number Range by Percentage

For this example, the MultiWeightGen Generator will be used to generate a range of specific values for a specified percentage.

To do so, three RangeGen Generators will need to be added as Linked Generators and then referenced by the MultiWeightGen Generator.

  • 1 to 99 – Generated 10% of the time
  • 100 to 199 – Generated 25% of the time
  • 200 to 499 – Generated 65% of the time

Step 1: Add three RangeGen Generators to the Attribute

Click on the Add Generator button.

Enter RangeGen into the filter input field and click on the Plus (+) to select the RangeGen Generator.

Repeat these steps two more times to add two more RangeGen Generators.

Step 2: Add the MultiWeightGen Generator

Click on the Add Generator button.

Enter MultiWeightGen into the filter input field and click on the Plus (+) to select the MultiWeightGen Generator.

The Linked Generators table will appear as shown below:

Step 3: gen1 Configuration

Select the gen1 Generator. For gen1, the endRange Parameter value will need to be changed.

It will be changed to 99. Remember to click the Save Generator button once finished.

Step 4: gen2 Configuration

Select the gen2 Generator. For gen2, both the startRange and endRange Parameter values will need to be changed.

The following values have been entered:

  • startRange = 100
  • endRange = 199

Note: Remember to click the Save Generator button once finished.

Step 5: gen3 Configuration

Select the gen3 Generator. For gen3, both the startRange and endRange Parameter values will need to be changed.

The following values have been entered:

  • startRange = 200
  • endRange = 499

Note: Remember to click the Save Generator button once finished.

Step 6: Reference gen1, gen2, and gen3 in the MultiWeightGen Generator

Select the MultiWeightGen Generator.

Double click on the valueList Parameter input field to reference a Generator.

Select the Attribute Generator Tab and click on the Plus (+) to select a Generator.

Repeat these steps for gen2 and gen3:

Step 7: Enter each corresponding value within the percentageList Parameter to match the referenced Generators in the valueList Parameter. Then press the Enter key.

For this example, the following percentage values have been entered:

  • 10
  • 25
  • 65

Step 8: Set the exactPercentage to “True”

Note: Remember to click the Save Generator button.

Generated Output Data

Related Assets

GenRocket - Test Data Management

Download Literature

View Literature
GenRocket - Test Data Management

View Blog

Read More
GenRocket - Test Data Management

How can we help
you today?

Request a Demo

See how GenRocket can solve your toughest test data challenge with quality synthetic data by-design and on-demand