random_choices
Select k items from a population with optional weighted probabilities. Use this tool for random sampling with replacement in applications requiring weighted or unbiased selections.
Instructions
Choose k items from population with replacement, optionally weighted.
Args: population: List of items to choose from k: Number of items to choose (default 1) weights: Optional weights for each item (default None for equal weights)
Returns: List of k chosen items
Input Schema
Name | Required | Description | Default |
---|---|---|---|
k | No | ||
population | Yes | ||
weights | No |
Input Schema (JSON Schema)
{
"properties": {
"k": {
"default": 1,
"title": "K",
"type": "integer"
},
"population": {
"items": {},
"title": "Population",
"type": "array"
},
"weights": {
"anyOf": [
{
"items": {
"anyOf": [
{
"type": "integer"
},
{
"type": "number"
}
]
},
"type": "array"
},
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Weights"
}
},
"required": [
"population"
],
"type": "object"
}