Repository navigation
Description
Task
T-023· Milestone M2 — Scenario + kinematic2d · Size S · Priority P0 · Epic #2Implements FR-SEL-001
Branch
feat/t-023-samplers-uniform-prior-inverse-cdf— one task = one branch = one PR (doc 32 §6)
Summary
Implement the Sampler protocol and UniformSampler, PriorSampler, LatinHypercubeSampler, SobolSampler, GridSampler in scenario/samplers.py (doc 05 §3, doc 07 §3).
Context / motivation
Baselines (S-RANDOM/LHS/SOBOL/GRID), S-PROBE warm-up and the risk-volume QMC all reuse these samplers; getting their statistics right is essential for a fair comparison.
Scope
In scope
sample(n, rng) -> (n,d)in the unit cube; prior inverse-CDF mapping (loguniform for P3 → uniform in unit space because the scale is log — document the interaction of prior and scale carefully).- LHS:
scipy.stats.qmc.LatinHypercube(d, optimization='random-cd', seed=…). - Sobol:
qmc.Sobol(d, scramble=True, seed=…), block draws of2^m, power-of-two warning suppressed. - Grid:
levelsper dimension at{0, 1/(k−1), …, 1}. - Seeds derived from the injected
Generator(no global RNG).
Implementation guidance
- SciPy
seed=accepts a Generator; passrngto keep determinism. Sobol state needs to be resumable for strategies → exposeskip(n)/fast_forward. - Standards: respect the layering contracts (doc 16 §2) and conventions in doc 34; no hard-coded tunables — thresholds/defaults come from typed settings (doc 27); no magic numbers (ruff
PLR2004); public APIs typed (mypy strict) and documented.
Acceptance criteria
- Distribution tests: KS test vs uniform for each marginal (p > 0.01 over fixed seeds).
- LHS: exactly one sample per stratum per dimension.
- Sobol prefix of 2^m has balance property; deterministic with seed.
- Grid size
k^dand ordering documented. - Tests listed below added and green in CI; coverage of new code meets the gate in doc 18 §3.
- Docs, config reference and CHANGELOG
Unreleasedupdated where behaviour, keys or interfaces changed. - Definition of Done (doc 32 §3) satisfied.
Tests required
tests/unit/scenario/test_samplers.py.
Dependencies
Blocked by: #34 (T-021)
Blocks: #84 (T-050a), #105 (T-100b), #136 (T-077)
Parallelization notes
Files / paths owned by this task — avoid editing other paths; shared files (pyproject.toml entry points, cli/main.py, api/routers/__init__.py, router.tsx, docker/compose.yaml, ci.yml) are append-only:
backend/src/roboprobe/scenario/samplers.pybackend/tests/unit/scenario/test_samplers.py
Owns samplers.py.
Definition of Done
Per doc 32 §3 and AGENTS.md §5: lint, format, mypy strict and import-linter green; tests added and passing; docs updated; PR template completed with Closes #<this issue>; Conventional Commit messages referencing T-023 (doc 16 §6); commits authored only by the repository owner identity (AGENTS.md §4); CI green; reviewer checklist (doc 32 §5.1) satisfied.
References
Design docs: doc 05 §3 · doc 07 §3 · doc 09 §5.4
Requirements: FR-SEL-001 (traceability: doc 28)
External:
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsBacklog
Activity