{
  "schema": "bidvariance.formulas.v1",
  "formulas": [
    {
      "name": "Beta-PERT parameters (λ = 4)",
      "formula": "alpha = 1 + 4 * (M - O) / (P - O); beta = 1 + 4 * (P - M) / (P - O)",
      "notes": "Sampled value = O + Beta(alpha, beta) * (P - O). When O = M = P the value is deterministic. The mean of this distribution equals (O + 4M + P) / 6."
    },
    {
      "name": "PERT mean",
      "formula": "mean = (O + 4M + P) / 6",
      "notes": "Classic PERT weighted average; the expected value under Beta-PERT with lambda = 4."
    },
    {
      "name": "PERT standard deviation",
      "formula": "sd = (P - O) / 6",
      "notes": "Classic approximation used for single three-point estimates and the free calculators."
    },
    {
      "name": "Exact Beta-PERT standard deviation",
      "formula": "sd = (P - O) * sqrt(alpha * beta / ((alpha + beta)^2 * (alpha + beta + 1)))",
      "notes": "Uses the Beta-PERT shape parameters above. Distinct from the classic range/6 approximation; zero for deterministic estimates."
    },
    {
      "name": "Task cost (per simulated run)",
      "formula": "taskCost = fixedCost + sampledDuration * dailyBurnRate + taskRiskCost",
      "notes": "A task-attributed risk adds its sampled cost when it fires; its schedule impact extends that task's finish time without adding burn cost."
    },
    {
      "name": "Total project cost (per simulated run)",
      "formula": "totalCost = sum(taskCosts) + riskCosts + projectFixedCosts + overhead",
      "notes": "Transparent aggregation; overhead is a fixed allocation, never a percentage, so it cannot be double-counted."
    },
    {
      "name": "Project duration (per simulated run)",
      "formula": "duration = max over tasks of (earliestStart + sampledDuration + riskDelays), earliestStart = max(finish of all predecessors)",
      "notes": "Finish-to-Start dependencies traversed in topological order; independent tasks run in parallel. Project-level risks add delay to the final finish."
    },
    {
      "name": "Gross margin",
      "formula": "grossMargin = (contractPrice - totalCost) / contractPrice",
      "notes": "Undefined when contractPrice <= 0. Not markup."
    },
    {
      "name": "Probability of loss",
      "formula": "P(loss) = share of runs where totalCost > contractPrice",
      "notes": "Measured empirically across all simulation iterations."
    },
    {
      "name": "Probability of target margin",
      "formula": "P(target) = share of runs where totalCost <= contractPrice * (1 - targetMargin)",
      "notes": "Equivalent to P(grossMargin >= targetMargin) since price is fixed."
    },
    {
      "name": "Deadline confidence",
      "formula": "confidence = share of runs where projectDuration <= daysBetween(plannedStart, promisedDate)",
      "notes": "Requires both a planned start and a promised completion date."
    },
    {
      "name": "Minimum defensible quote (reverse pricing)",
      "formula": "requiredPrice = costQuantile(confidence) / (1 - targetMargin)",
      "notes": "Exact closed form while price does not affect cost (true for the current model). Example: P80 cost 92,000 at 25% target margin -> 92,000 / 0.75 = 122,666.67. If price-dependent costs are ever introduced, a numerical solver replaces this formula."
    },
    {
      "name": "Percentiles",
      "formula": "quantile(p): linear interpolation between adjacent order statistics (type 7)",
      "notes": "P50 is the median; P80/P90 are higher-confidence references, not guarantees."
    }
  ]
}
