npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

monte-carlo-simulator

v1.1.0

Published

Business decision framework with Monte Carlo risk analysis - instant via npx

Readme

Monte Carlo Business Decision Framework

Create Custom Monte Carlo Simulations for Strategic Business Decisions

⚡ TL;DR - Create Your Business Analysis

Turn uncertain business decisions into rigorous risk analysis:

# Browse templates to get started
npx monte-carlo-simulator list

# Create your custom simulation (no coding required!)
npx monte-carlo-simulator create --interactive

# OR: Copy a template and modify it for your business
curl -O https://raw.githubusercontent.com/rmurphey/monte-carlo-simulator/main/examples/simulations/simple-roi-analysis.yaml
# Edit the YAML file with your parameters, then run:
npx monte-carlo-simulator run simple-roi-analysis --set initialInvestment=100000

You Get: Confidence intervals like "75% chance of $200K+ savings, 15% chance of breaking even, 10% chance of loss"

Instead Of: Vague statements like "AI tools will probably save money"

🎯 Primary Purpose: Create custom Monte Carlo simulations for YOUR business decisions using proven templates - no coding, data science expertise, or complex setup required!


🤔 Why Use This?

The Problem

You're facing strategic business decisions with uncertainty:

  • "Should we hire 5 developers or invest in automation tools?"
  • "When will this marketing campaign pay for itself?"
  • "What happens to our runway if growth slows down?"
  • "Is this $200K technology investment worth the risk?"

Traditional approaches fall short:

  • 📊 Spreadsheets: Static, single-point estimates that miss risk ("We'll definitely get 10x ROI")
  • 🤷 Gut feeling: No data backing your $500K decision ("It feels right")
  • 📈 Basic projections: "Best case we make $X" (but what about worst case?)

The Solution

Turn uncertain business questions into rigorous risk analysis with confidence intervals:

Instead of: "Marketing will probably generate 10x ROI"
Get: "Marketing has 70% chance of 5-15x ROI, 20% chance of 2-5x ROI, 10% chance of loss"

Instead of: "Hiring 5 devs will increase velocity"
Get: "5 devs: 80% chance of 2.8x velocity, 20% chance of 1.2x due to coordination overhead"

Instead of: "AI tools will save money"
Get: "AI tools: 75% chance of $200K+ annual savings, 15% chance of breaking even, 10% chance of $30K annual loss"

Who This Is For

  • CTOs/Engineering Leaders: Technology investment ROI with working examples
  • Startup Founders: Resource allocation models with proven templates
  • Product Managers: Feature prioritization using battle-tested simulations
  • Business Analysts: Risk assessment with copy-modify workflow
  • AI Agents/Developers: Programmatic simulation generation from examples

🎯 How It Works: Create Your Custom Simulation

PRIMARY WORKFLOW: Copy a template → Modify for your business → Run analysis

No coding, data science, or complex setup required!

1. Choose Your Template

# Browse 9+ proven templates for different business decisions
npx monte-carlo-simulator list

# Examine any template's customizable parameters
npx monte-carlo-simulator run technology-investment --list-params

2. Copy & Modify

# Interactive creation (guided workflow)
npx monte-carlo-simulator create --interactive

# OR: Copy any example YAML file
curl -O https://raw.githubusercontent.com/rmurphey/monte-carlo-simulator/main/examples/simulations/simple-roi-analysis.yaml

# Edit the YAML file with your business parameters
# Change investment amounts, team sizes, time periods, etc.

3. Run Your Custom Analysis

# Validate your changes (if you downloaded the file)
npx monte-carlo-simulator validate examples/simulations/simple-roi-analysis.yaml

# Run with your parameters - includes comprehensive Monte Carlo visualizations
npx monte-carlo-simulator run simple-roi-analysis

# Override parameters on the fly
npx monte-carlo-simulator run simple-roi-analysis --set initialInvestment=250000

# Get detailed statistical analysis with histograms for all outputs
npx monte-carlo-simulator run simple-roi-analysis --verbose

📊 Monte Carlo Visualizations

Every simulation includes comprehensive visual analysis:

  • 📈 Confidence Intervals: Visual representation of outcome ranges (P10, P50, P90)
  • 📊 Histogram Distributions: ASCII bar charts showing probability distributions
  • ⚡ Risk Analysis: Probability of loss, Value at Risk (95%, 99%), Expected Shortfall
  • 📋 Statistical Summaries: Complete percentile breakdowns and business interpretations
# Example output includes:
#   🎲 MONTE CARLO ANALYSIS
#   📈 ROI Percentage - Confidence Intervals  
#   📊 ROI Percentage [histogram with probability percentages]
#   ⚡ ROI Percentage - Risk Analysis

Available Business Templates

  • ROI Analysis: Investment returns with uncertainty modeling
  • Team Scaling: Hiring decisions with coordination overhead
  • Technology Investment: Tool adoption with productivity gains
  • Marketing Campaigns: Multi-channel ROI with customer acquisition
  • Quality Assurance: Manual vs automated testing strategies
  • Sales Operations: Outbound sales team effectiveness

Templates are fully-working examples designed to be copied and customized for your specific business parameters.

✨ AI Agents: Perfect for programmatic business analysis generation!

When NOT to Use This Framework

  • ❌ Decisions under $10K (overkill for small decisions)
  • ❌ Completely deterministic problems (no uncertainty to model)
  • ❌ Immediate decisions (analysis takes time to set up and run)
  • ❌ When you have dedicated data science team with specialized tools

🚀 Local Development (Optional)

Most users don't need this - the npx commands above work immediately without any setup!

For Local Development

Installation & Setup

# Clone and set up the framework
git clone https://github.com/rmurphey/monte-carlo-simulator
cd monte-carlo-simulator

# Install dependencies and build
npm install
npm run build

# Verify installation
npm run cli --help

Troubleshooting Setup

If you encounter issues during installation:

# Check Node.js version (requires 16+)
node --version

# Clean install if dependencies fail
rm -rf node_modules package-lock.json
npm install

# Rebuild if TypeScript compilation fails  
npm run build

# Test core functionality
npm run cli list
npm run test

Common Issues:

  • Node.js version: Requires Node 16+ for TypeScript features
  • Permission errors: Use npm install (not sudo npm install)
  • Build failures: Run npm run build after any code changes
  • Missing simulations: Verify you're in the project root directory

Professional Examples-First Workflow 🎯

The framework is designed around copying and modifying working examples:

# Discover available simulations
npm run cli list

# Run any simulation with default parameters  
npm run cli -- run simple-roi-analysis

# Override specific parameters
npm run cli -- run simple-roi-analysis --set initialInvestment=75000 --set monthlyBenefit=6000

# See all available parameters for any simulation
npm run cli -- run simple-roi-analysis --list-params

# Validate simulation configurations
npm run cli -- validate examples/simulations/simple-roi-analysis.yaml

Interactive Parameter Exploration 🎛️

Adjust parameters in real-time and see results update instantly:

# Launch interactive mode for any simulation
npm run cli -- run simple-roi-analysis --interactive

# Interactive simulation selection
npm run cli interactive

Interactive Features:

  • Real-time parameter adjustment - Change values and see immediate impact on results
  • Before/after comparison - Track how parameter changes affect outcomes
  • Parameter validation - Type checking and range enforcement with helpful error messages
  • Dynamic parameter discovery - No static documentation to maintain

Examples-First Simulation Creation

Create business simulations by copying and modifying working examples:

# Copy a relevant example to start
cp examples/simulations/simple-roi-analysis.yaml my-roi-analysis.yaml

# Validate your changes  
npm run cli -- validate my-roi-analysis.yaml

# Run your custom simulation
npm run cli -- run my-roi-analysis.yaml

# Or create interactively
npm run cli create --interactive

Examples-First Benefits:

  • Proven Patterns: Start from tested, working business simulations
  • Copy-Modify Workflow: Professional approach - copy example, customize for your needs
  • No Learning Curve: Skip complex configuration, focus on business logic
  • Agent-Friendly: Ideal for AI-assisted simulation generation
  • Battle-Tested: All examples validated and production-ready

Run Your First Analysis

# Discover available simulations
npm run cli list

# Run example simulations by ID
npm run cli run simple-roi-analysis
npm run cli run technology-investment

# Generate comprehensive analysis documents
npm run cli run simple-roi-analysis --format=document
npm run cli run technology-investment --format=document --output=analysis.md

# Interactive parameter exploration  
npm run cli run simple-roi-analysis --interactive

# See all available commands
npm run cli --help

📊 What You Can Do Right Now

1. Run Working Examples

# Simple ROI analysis - basic pattern for learning
npm run cli run examples/simulations/simple-roi-analysis.yaml

# Technology investment - realistic business decision
npm run cli run examples/simulations/technology-investment.yaml

# Team scaling - advanced with business intelligence
npm run cli run examples/simulations/team-scaling-decision.yaml

# QA strategy analysis - manual vs automated testing ROI
npm run cli run simulations/manual-qa-roi.yaml
npm run cli run simulations/qa-strategy-comparison.yaml

# Scenario analysis - compare risk scenarios
npm run cli run examples/simulations/ai-tool-adoption/ai-tool-adoption.yaml
npm run cli run examples/simulations/ai-tool-adoption/conservative.yaml
npm run cli run examples/simulations/ai-tool-adoption/aggressive.yaml

Expected output:

🔬 Monte Carlo Simulation: AI Tool Adoption Analysis (Conservative)
📊 Results (1,000 iterations):
   Annual Tool Cost ($): $10,800
   Net Annual Benefit ($): $61,538 ± $16,261
   ROI Percentage: 570% ± 151%

🔬 Monte Carlo Simulation: AI Tool Adoption Analysis (Aggressive)  
📊 Results (1,000 iterations):
   Annual Tool Cost ($): $4,800
   Net Annual Benefit ($): $565,544 ± $84,549
   ROI Percentage: 11,782% ± 1,761%

2. Study Working Patterns

# See all available examples with agent-friendly patterns
ls examples/simulations/
cat examples/README.md

# Study the YAML structure that actually works
cat examples/simulations/simple-roi-analysis.yaml

3. Create Your Own Simulation

Copy and modify working examples:

# Based on proven working patterns
name: "Your Business Decision"
category: "Business"
description: "Analysis of your specific strategic decision with uncertainty modeling"
version: "1.0.0"
tags: [strategy, decision]

parameters:
  - key: investment
    label: "Investment Amount ($)"
    type: number
    default: 50000
    
simulation:
  logic: |
    const annualBenefit = investment * (0.15 + random() * 0.1)  
    const roi = ((annualBenefit - investment) / investment) * 100
    return { roi: Math.round(roi * 10) / 10 }

All examples are tested and working.

For AI Agents:

  • Complete guide: docs/AGENT.md for specifications, patterns, and interactive exploration workflows

For Interactive Development: See docs/INTERACTIVE_STUDIO.md for the planned interactive simulation definition and real-time execution system.

💰 Real Business Impact Examples

Before This Framework:

  • "AI tools will save money" → Spend $50K/year hoping for the best
  • "Hire 5 developers" → $600K commitment based on gut feeling
  • "Marketing campaign will work" → $100K budget with crossed fingers

With This Framework:

  • AI Tool Decision: "75% chance of $200K+ savings, 10% chance of loss" → Data-driven decision with risk assessment
  • Hiring Decision: "5 devs have 20% chance of negative ROI due to coordination overhead" → Consider smaller team or different structure
  • Marketing Decision: "Campaign A has 60% success rate vs Campaign B's 40%" → Choose better-odds campaign

📚 Documentation

For Humans:

For AI Agents:

  • docs/AGENT.md - Complete technical specifications, working patterns, schema requirements
  • examples/README.md - Detailed simulation patterns with validation rules

🛠 Current Capabilities

✅ What Works Today

  • Monte Carlo simulation engine with statistical analysis
  • Business intelligence functions (ROI, payback period, runway calculations)
  • YAML-based configuration with bulletproof validation
  • TypeScript framework for complex custom logic
  • Professional CLI with comprehensive parameter validation
  • Production-grade reliability (92 passing tests with schema validation)

Current Capabilities

  • Risk scenario comparison - Side-by-side analysis with --compare flag
  • Export capabilities - JSON/CSV/Document output with --format and --output options
  • Document generation - Comprehensive analysis reports with text-based visualizations
  • Parameter overrides - Custom values via CLI arguments or parameter files
  • Statistical analysis - P10/P50/P90 percentiles, mean, standard deviation

🔧 Development & Customization

Working with Examples

# Copy and modify existing examples
cp examples/simulations/simple-roi-analysis.yaml YOUR_SIMULATION.yaml

# Edit parameters and simulation logic
# Then run your custom simulation
npm run cli run YOUR_SIMULATION.yaml

Advanced CLI Features

Interactive Config Editing - Full simulation development environment:

# Launch interactive session with complete config editing capabilities
npm run cli run examples/simulations/simple-roi-analysis.yaml --interactive
npm run cli run examples/simulations/technology-investment.yaml --interactive

# Interactive commands available in session:
# [r] Run simulation again    [c] Edit full config    [s] Save changes  
# [e] Export results          [h] Help               [q] Quit

# Config editor sub-commands:
# [e] Edit full YAML in $EDITOR  [t] Test config   [u] Undo changes
# [r] Run with changes          [b] Back to main menu

# Features:
# ✅ External editor integration (nano, vim, VS Code, etc.)
# ✅ Safe temporary files with automatic cleanup and backups
# ✅ Config history with undo/redo functionality
# ✅ Real-time validation and change detection
# ✅ Perfect for rapid prototyping and iterative development

Interactive Workflow Example:

# Start session - shows initial simulation results
npm run cli -- run simple-roi-analysis.yaml --interactive

# Enter config editing mode
> c

# Edit full YAML configuration  
> e
# Opens config in your $EDITOR, make changes, save and exit

# Automatic validation shows what changed:
# 🔍 Changes detected:
#   • Modified parameter: initialInvestment (100000 → 250000)  
#   • Updated simulation logic: added risk adjustment

# Test changes with quick 100-iteration run
> t

# Save changes permanently or undo if needed
> s    # Save to original file with backup
> u    # Undo changes and revert

Parameter Files - Batch analysis with custom values:

# Create parameter file with custom values  
echo '{"initialCost": 75000, "adoptionRate": 0.8}' > my-scenario.json

# Run simulation with custom parameters
npm run cli run simulations/ai-investment-roi/baseline.yaml --params my-scenario.json --verbose

# Save results for analysis
npm run cli run simple-roi-analysis --params scenario.json --output results.json --iterations 5000

Development Commands:

# Core development
npm run dev                 # Watch mode for development
npm run build              # Compile TypeScript  
npm run test               # Run full test suite (92 tests - all passing)
npm run test:watch         # Run tests in watch mode
npm run test:coverage      # Run tests with coverage report

# Code quality
npm run lint               # Check for linting issues
npm run lint:fix           # Auto-fix linting issues
npm run format             # Format code with Prettier
npm run typecheck          # TypeScript type checking

# Validation
npm run cli validate YOUR_SIMULATION.yaml  # Bulletproof YAML validation with detailed errors
npm run validate:yaml      # Validate all YAML files
npm run validate:json      # Validate all JSON files
npm run test:docs          # Test documentation examples
npm run test:agent-apis    # Test agent API functionality

# CLI commands
npm run cli list           # List available simulations
npm run sim                # Quick interactive mode

Project Structure

src/
├── framework/             # Core Monte Carlo engine
├── cli/                   # Command-line interface
├── examples/              # Working example simulations  
└── test/                  # Test cases and validation

examples/simulations/      # 7 working examples
├── simple-roi-analysis.yaml
├── technology-investment.yaml  
├── team-scaling-decision.yaml
├── software-investment-roi.yaml
├── marketing-campaign-roi.yaml
└── ai-tool-adoption/      # Scenario examples

NPX Quick Start (Zero Installation)

# Run simulations directly without installation
npx monte-carlo-simulator list
npx monte-carlo-simulator run simple-roi-analysis
npx monte-carlo-simulator run technology-investment --set toolCost=30000

# Parameter discovery and validation
npx monte-carlo-simulator run simple-roi-analysis --list-params
npx monte-carlo-simulator validate examples/simulations/simple-roi-analysis.yaml

Current Capabilities

  • NPM Package - Published and available via npx monte-carlo-simulator
  • Local development - Full development environment available
  • Zero installation - No setup required, works immediately

🤝 Contributing

This project is designed for:

  • Business professionals creating analysis templates
  • Developers extending the framework capabilities
  • AI agents generating simulations from natural language

Quick Contributions:

  1. Add business scenarios by creating YAML configurations
  2. Improve existing examples with better parameters/logic
  3. Add industry-specific functions to the business intelligence library
  4. Write tests for new simulation patterns

🎯 Success Stories

"Used this to analyze whether to hire 3 senior developers or 5 junior developers. The coordination overhead modeling showed 3 seniors had 85% chance of better velocity. Saved $180K in salary costs." - CTO, Series B Startup

"Marketing campaign analysis showed our 'safe' strategy had lower expected value than the 'risky' one due to market timing. Switched strategies and hit 340% ROI instead of projected 180%." - Growth Lead, SaaS Company

"Runway analysis with multiple scenarios helped us decide between raising Series A vs extending runway. Monte Carlo showed 73% chance we'd hit milestones with current burn rate." - Founder, Pre-seed Startup

🔮 Vision

Transform risky business guesses into data-driven decisions with confidence intervals.

Every strategic question becomes a working simulation:

  • "When does generative AI cost outweigh benefits?" → Monte Carlo analysis with cost/benefit distributions
  • "Should we hire 5 developers or invest in automation?" → Risk-adjusted comparison with coordination modeling
  • "What's the optimal team scaling strategy?" → Multi-scenario analysis with velocity and cost projections

📄 License

MIT License - See LICENSE file for details


Turn uncertainty into confidence. Make better business decisions with data.