Agent skill

numpy-random

Stars 0
Forks 0

Install this agent skill to your Project

npx add-skill https://github.com/cuba6112/skillfactory/tree/main/skills/numpy-random

SKILL.md

Overview

NumPy's random module shifted from the legacy RandomState to the modern Generator API. This new approach provides better statistical properties, faster algorithms, and a robust system for parallel random number generation using SeedSequence.

When to Use

  • Stochastic simulations requiring high-quality random bits.
  • Shuffling datasets for machine learning training.
  • Generating independent random streams for parallel computing workers.
  • Creating reproducible experiments across different runs.

Decision Tree

  1. Starting a new project?
    • Use np.random.default_rng(). Do not use np.random.seed().
  2. Need independent streams for multiple CPUs?
    • Use SeedSequence.spawn() to create children.
  3. Shuffling in-place?
    • Use rng.shuffle(arr). For a copy, use rng.permuted(arr).

Workflows

  1. Parallel Random Stream Generation

    • Initialize a SeedSequence with a high-quality entropy source.
    • Use the .spawn(n) method to create independent seed sequences for workers.
    • Instantiate a new Generator for each worker using its specific child sequence.
  2. Reproducible Simulation Setup

    • Obtain a 128-bit seed (e.g., using secrets.randbits(128)).
    • Initialize the generator: rng = np.random.default_rng(seed).
    • Log the seed to allow exact reproduction of the stochastic results in future runs.
  3. In-Place Array Shuffling

    • Create a Generator instance.
    • Pass an existing array to rng.shuffle(arr) to modify it in-place.
    • Specify the axis parameter if only certain dimensions (e.g., rows) should be rearranged.

Non-Obvious Insights

  • Legacy Discouragement: RandomState is essentially in maintenance mode; Generator is faster and has better statistical distribution qualities.
  • Small Seed Limitation: Seeding with small integers (0-100) limits the reachable state space; SeedSequence ensures high-entropy starting states.
  • Bitstream Instability: Even with the same seed, the bitstream is not guaranteed to be identical across different NumPy versions due to algorithmic improvements.

Evidence

  • "In general, users will create a Generator instance with default_rng and call the various methods on it to obtain samples." Source
  • "SeedSequence mixes sources of entropy in a reproducible way to set the initial state for independent and very probably non-overlapping BitGenerators." Source

Scripts

  • scripts/numpy-random_tool.py: Implements parallel seed spawning and reproducible RNG.
  • scripts/numpy-random_tool.js: Basic random sampling logic.

Dependencies

  • numpy (Python)

References

  • references/README.md

Expand your agent's capabilities with these related and highly-rated skills.

cuba6112/skillfactory

prompt-engineering

Comprehensive prompt engineering techniques for Claude models. Use this skill when crafting, optimizing, or debugging prompts for Claude API, Claude Code, or any Claude-powered application. Covers system prompts, role prompting, multishot examples, chain of thought, XML structuring, long context handling, extended thinking, prompt chaining, Claude 4.x-specific best practices, and agentic orchestration including subagents, agent loops, skills, MCP integration, and multi-agent workflows.

0 0
Explore
cuba6112/skillfactory

adk-rag-agent

Build RAG (Retrieval-Augmented Generation) agents with Google ADK and Vertex AI RAG Engine. Use when implementing document Q&A, knowledge base search, or citation-backed responses. Covers VertexAiRagRetrieval tool, corpus setup, and citation formatting.

0 0
Explore
cuba6112/skillfactory

headless-cli-agents

Build agentic systems using Claude CLI in headless mode or the Claude Agent SDK. Use when building automation pipelines, CI/CD integrations, multi-agent orchestration, or programmatic Claude interactions. Covers CLI flags (-p, --output-format), session management (--resume, --continue), Python SDK (claude-agent-sdk), custom tools, and agent loop patterns.

0 0
Explore
cuba6112/skillfactory

notion-knowledge-capture

Capture conversations and decisions into structured Notion pages; use when turning chats/notes into wiki entries, how-tos, decisions, or FAQs with proper linking.

0 0
Explore
cuba6112/skillfactory

mcp-builder

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

0 0
Explore
cuba6112/skillfactory

gh-fix-ci

Inspect GitHub PR checks with gh, pull failing GitHub Actions logs, summarize failure context, then create a fix plan and implement after user approval. Use when a user asks to debug or fix failing PR CI/CD checks on GitHub Actions and wants a plan + code changes; for external checks (e.g., Buildkite), only report the details URL and mark them out of scope.

0 0
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results