Skip to content

Latest commit

 

History

History
31 lines (24 loc) · 1.53 KB

File metadata and controls

31 lines (24 loc) · 1.53 KB

Phase 9d: Statistical Aggregations (Completed)

Status: Completed (2025-12-22)

This phase added advanced statistical aggregation functions to the Go target, supporting both simple and grouped aggregation modes.

Delivered Features

1. New Aggregation Operations

  • stddev(Field, Result): Sample Standard Deviation.
    • Implemented using Welford's Online Algorithm for single-pass efficiency and numerical stability.
    • O(1) memory per group.
  • median(Field, Result): Median value.
    • Implemented with value collection and sort.Float64s.
    • O(n) memory per group (required for median).
  • percentile(Field, P, Result): P-th Percentile.
    • Supports arbitrary percentiles (e.g., 90th, 95th, 99th).
    • Uses linear interpolation between closest ranks.

2. Full Integration

  • Simple Aggregations: Works with aggregate(Op, Goal, Result).
  • Grouped Aggregations: Works with group_by(Group, Goal, Op, Result) and multi-aggregation lists.
  • HAVING Clause: Fully supported in post-aggregation filtering (e.g., group_by(...), StdDev > 5.0).
  • Target Support: Currently implemented for Go (Bbolt and JSONL modes).

3. Smart Code Generation

  • Conditional Imports: Only imports math or sort if the operations require them.
  • Helper Injection: Automatically injects necessary Go helper functions for median and percentile calculations.

Verification

  • tests/test_go_stats.pl: Verified stddev, median, and percentile in both simple and grouped modes, including HAVING clause integration.