Random Number
Controlled node
Overview
Generates a random number within a specified range. The node supports both seeded and unseeded random number generation, allowing for reproducible results when needed. By default, it generates integers between 0 and 100, but supports custom ranges and decimal precision.
Seeded Random Generation
When a seed value is provided, the node uses a deterministic random number generator (mulberry32 algorithm) that produces the same sequence of numbers for the same seed. This is useful for:
- Reproducible workflows
- Testing and debugging
- Consistent random sampling
If no seed is provided, the node uses JavaScript's Math.random() for non-deterministic results.
Inputs
| Input | Type | Description | Default |
|---|---|---|---|
| Run | Event | Triggers the node to generate a random number | - |
Outputs
| Output | Type | Description |
|---|---|---|
| Output | Number | The generated random number |
| Done | Event | Fires when the node has finished generating the number |
Properties
| Property | Type | Description | Default |
|---|---|---|---|
| Min | Number | The minimum value of the range (inclusive) | 0 |
| Max | Number | The maximum value of the range (inclusive) | 100 |
| Decimals | Number | Number of decimal places to round to (0 for integers) | 0 |
| Seed | Text | Optional seed string for reproducible random generation | - |
Runtime Behavior
Range Handling
- The node generates values in the range [min, max] (inclusive)
- If Min is greater than Max, the values are automatically swapped
- Decimal precision is applied using standard rounding rules
Seeding Behavior
- When Seed is provided and non-empty, the node uses the mulberry32 algorithm seeded with a hash of the seed string
- The same seed will always produce the same output value
- When Seed is empty or not provided, the node uses
Math.random()for non-deterministic output
Defaults
- Min: 0
- Max: 100
- Decimals: 0 (integers only)
- Seed: Empty (non-deterministic)
Example Usage
Basic Random Integer
To generate a random integer between 1 and 10:
- Set Min to
1 - Set Max to
10 - Set Decimals to
0(or leave as default) - Leave Seed empty
- Trigger the Run event
Reproducible Random Decimal
To generate a reproducible random number between 0 and 1 with 2 decimal places:
- Set Min to
0 - Set Max to
1 - Set Decimals to
2 - Set Seed to a specific string (e.g.,
"experiment-1") - Trigger the Run event
Use the Seed property when you need the same random number every time the workflow runs. This is particularly useful for testing or when you need consistent results across multiple runs.