{"record":{"id":"db5d185862534776","repo":"rohitg00/ai-engineering-from-scratch","slug":"probability-must-be-between-zero-and-one","errorCode":null,"errorMessage":"probability must be between zero and one","messagePattern":"probability must be between zero and one","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"certifications/claude/lessons/26-production-observability-latency-and-cost/code/main.py","lineNumber":34,"sourceCode":"@dataclass(frozen=True)\nclass Trace:\n    trace_id: str\n    variant: str\n    duration_ms: int\n    input_tokens: int\n    output_tokens: int\n    cost_usd: float\n    task_success: bool\n    system_ok: bool\n    cache_read: bool = False\n    error_category: str | None = None\n\n\ndef percentile(values: list[int], probability: float) -> float:\n    if not values:\n        return 0.0\n    if not 0 <= probability <= 1:\n        raise ValueError(\"probability must be between zero and one\")\n    ordered = sorted(values)\n    rank = max(0, math.ceil(probability * len(ordered)) - 1)\n    return float(ordered[rank])\n\n\ndef summarize(traces: list[Trace]) -> dict[str, object]:\n    if not traces:\n        return {\n            \"requests\": 0,\n            \"system_success_rate\": 0.0,\n            \"task_success_rate\": 0.0,\n            \"p50_ms\": 0.0,\n            \"p95_ms\": 0.0,\n            \"total_cost_usd\": 0.0,\n            \"cost_per_task_success_usd\": None,\n            \"cache_read_rate\": 0.0,\n            \"errors\": {},\n        }","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/certifications/claude/lessons/26-production-observability-latency-and-cost/code/main.py#L16-L52","documentation":"Error \"probability must be between zero and one\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at certifications/claude/lessons/26-production-observability-latency-and-cost/code/main.py:34 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}