random-selection

ljchg12-hue's avatarfrom ljchg12-hue

Randomly select items from lists using various algorithms for fair and unbiased selection

0stars🔀0forks📁View on GitHub🕐Updated Jan 6, 2026

When & Why to Use This Skill

The Random Selection skill enables users to perform fair and unbiased item selection from lists using advanced algorithms. It supports weighted selection, stratified sampling, and reproducible results with seeds, making it an essential tool for data scientists, researchers, and developers who require statistical integrity in their workflows.

Use Cases

  • A/B Testing: Assign participants to control and experimental groups with scientific randomness to ensure valid results.
  • Statistical Sampling: Extract representative subsets from large datasets for surveys or market research using stratified or reservoir sampling.
  • Prize Drawings and Giveaways: Ensure complete fairness and transparency in contests using unbiased selection algorithms.
  • Data Randomization: Shuffle lists or datasets for machine learning training or to eliminate order bias in automated processing tasks.
namerandom-selection
descriptionRandomly select items from lists using various algorithms for fair and unbiased selection

Random Selection Skill

Perform random selection with various algorithms for fair, unbiased outcomes.

When to Use

  • Prize drawings
  • Random sampling
  • A/B test group assignment
  • Survey participant selection

Core Capabilities

  • Simple random selection
  • Weighted random selection
  • Stratified sampling
  • Shuffle/randomize lists
  • Unique selection (no duplicates)
  • Reproducible randomness (seeded)

Examples

# Bash: Random line from file
shuf -n 1 items.txt

# Python: Simple random
import random
items = ['A', 'B', 'C', 'D']
selected = random.choice(items)

# Python: Multiple unique items
selected = random.sample(items, 2)

# Python: Weighted selection
weights = [10, 5, 3, 1]
selected = random.choices(items, weights=weights, k=1)

# Python: Seeded (reproducible)
random.seed(42)
selected = random.choice(items)

Algorithms

  • Uniform: Equal probability
  • Weighted: Based on weights
  • Reservoir sampling: For streams
  • Fisher-Yates shuffle: Unbiased shuffling

Best Practices

  • Use cryptographically secure random for security
  • Document seed for reproducibility
  • Verify distribution for large samples
  • Handle edge cases (empty list, single item)

Resources