Montecarlo subgroup prediction

From divinevideo/divine-mobile · View interactive version

Montecarlo subgroup prediction is an AI agent skill from the GitHub repository divinevideo/divine-mobile. Fix Monte Carlo project completion simulations that give identical dates for all sub-groups (milestones, priorities, epics). Use when: (1) All sub-group predictions converge to the same date despite different remaining counts, (2) Proportional throughput scaling produces flat/identical results, (3)

How to use this skill

Skill file

Monte Carlo Sub-Group Prediction Scaling

Problem

When running Monte Carlo simulations for project completion, predicting dates for

sub-groups (milestones, priorities, epics) within a larger project produces identical

results for all groups, or simulations diverge and hit the max_weeks cap.

Context / Trigger Conditions

or priority groups within a larger project backlog

(e.g., 5-item milestone shows same date as 46-item milestone)

Root Causes

1. Proportional Scaling is Mathematically Constant

If you scale throughput proportionally:

share = remaining_i / total_remaining
scaled_throughput = overall_throughput * share
weeks = remaining_i / scaled_throughput
      = remaining_i / (overall_throughput * remaining_i / total_remaining)
      = total_remaining / overall_throughput  # CONSTANT for all groups!

Every sub-group predicts the same number of weeks regardless of size.

2. Overall Scope Rate Overwhelms Sub-Group Throughput

If the project's overall scope rate is 50 items/week and you apply it to a sub-group

with only 5 remaining items (share = 1.6%), the scaled throughput might be ~0.6/week

while scaled scope is ~0.8/week. Net velocity is negative — the simulation never

converges and hits max_weeks.

3. GitHub `created_at` ≠ "Added to Board"

Scope rate calculated from created_at dates reflects when GitHub issues were created,

not when they were added to the project board. Bulk triaging or importing old issues

inflates the apparent scope rate dramatically.

Solution

Use different simulation models for different sub-group types:

For Sequential Priorities (P0, P1, P2...): Cumulative Model

Higher priorities are completed first. Each priority's prediction includes all

higher-priority work that must finish before it:

sorted_priorities = sorted(priorities, key=lambda p: p["name"])
cumulative_before = 0

for p in sorted_priorities:
    effective_remaining = cumulative_before + p["remaining"]
    result = simulate(
        remaining=effective_remaining,
        throughput_history=full_project_throughput,  # NOT scaled
        scope_rate=0.0,  # Don't apply scope per-group
    )
    result.remaining = p["remaining"]  # Show actual remaining
    cumulative_before += p["remaining"]

For Milestones/Epics: Hypergeometric Draw Model

Items from each milestone are randomly drawn from the overall work pool. Smaller

milestones finish earlier due to higher variance:

for i in range(n_simulations):
    subset_left = remaining
    pool_left = total_remaining
    weeks = 0
    while subset_left > 0 and weeks < max_weeks:
        throughput = rng.choice(throughput_samples)
        draw_size = min(throughput, pool_left)
        if draw_size > 0 and pool_left > 0:
            other = pool_left - subset_left
            # How many completed items come from this milestone?
            drawn = rng.hypergeometric(subset_left, max(other, 0), draw_size)
            subset_left -= drawn
            pool_left -= draw_size
            pool_left = max(pool_left, subset_left)
        weeks += 1

Key Principles

  1. Don't scale throughput proportionally — it produces identical results
  2. Don't apply overall scope rate to sub-groups — it causes divergence
  3. Use the full project throughput for priority predictions (cumulative model)
  4. Use hypergeometric sampling for milestone predictions (discrete draws)
  5. Show scope rate as informational rather than baking it into per-group MC

Verification

Example

With throughput of [2, 29, 44, 34, 11, 24, 33, 54, 34, 101, 57, 81, 0] and

303 total remaining items:

Before fix (proportional scaling):

MVP Rel 1 (5 left):   Apr 13    # All identical!
MVP Rel 2 (46 left):  Apr 13
Release 3 (33 left):  Apr 13

After fix (hypergeometric draws):

MVP Rel 1 (5 left):   Apr 6     # Differentiated by size
MVP Rel 2 (46 left):  Apr 13
Release 3 (33 left):  Apr 13
Zap Store (10 left):  Apr 13

Notes

is mathematically equivalent to "everything finishes when the project finishes"

because the differential equation d(subset)/dt = -T*(subset/pool) preserves ratios

without replacement from a mixed pool"

variance — this is correct and reflects genuine uncertainty

to prevent divergent simulations

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.