viewof wagg_sensorRate = Inputs.range([1, 100], {value: 1, step: 1, label: "Sensor Sample Rate (Hz)"})
viewof wagg_windowSec = Inputs.range([10, 600], {value: 60, step: 10, label: "Aggregation Window (seconds)"})
viewof wagg_bytesPerSample = Inputs.select([2, 4, 8], {value: 8, label: "Bytes per Raw Sample"})
viewof wagg_includeP95 = Inputs.toggle({value: true, label: "Include P95 percentile"})
viewof wagg_sensorCount = Inputs.range([1, 100], {value: 10, step: 1, label: "Number of Sensors"})Window Aggregation Calculator
Window Aggregation Calculator
animation
analytics-ml
edge-acquisition
Try Change Aggregation Window (seconds) from 60 to 600.
Observe Watch Samples per Window, Summary Size, and Compression Ratio after pressing Calculate.
Explain Describe how Include P95 percentile changes Summary Size after pressing Calculate.
Technical boundaries. Summary fields use 4 bytes each, including timestamp and optional p95. Aggregation loses individual sample timing, exact value sequences, and sub-window transient patterns.
NoteWindow Aggregation Calculator
Configure the sensor rate and aggregation window to see how statistical summaries compress continuous data while preserving trend and anomaly detection capability.
wagg_samplesPerWindow = wagg_sensorRate * wagg_windowSec
wagg_rawBytes = wagg_samplesPerWindow * wagg_bytesPerSample
// Output: timestamp(4) + count(4) + mean(4) + min(4) + max(4) + std(4) + optional p95(4)
wagg_statsFields = wagg_includeP95 ? 7 : 6
wagg_outputBytes = wagg_statsFields * 4
wagg_ratio = wagg_rawBytes / wagg_outputBytes
wagg_windowsPerHour = 3600 / wagg_windowSec
wagg_rawBytesPerHour = wagg_rawBytes * wagg_windowsPerHour * wagg_sensorCount
wagg_compBytesPerHour = wagg_outputBytes * wagg_windowsPerHour * wagg_sensorCount
wagg_rawDayMB = (wagg_rawBytesPerHour * 24) / (1024 * 1024)
wagg_compDayKB = (wagg_compBytesPerHour * 24) / 1024html`<div style="background: var(--bs-light, #f8f9fa); border: 1px solid var(--bs-border-color, #dee2e6); border-radius: 8px; padding: 1.2rem; color: var(--bs-body-color);">
<h4 style="margin-top:0; color: #2C3E50;">Window Aggregation Results</h4>
<table style="width:100%; border-collapse: collapse; font-size: 0.9rem;">
<tr style="border-bottom: 1px solid var(--bs-border-color, #dee2e6);">
<th scope="row" style="padding: 5px 8px; font-weight: normal; text-align: left;"><strong>Samples per Window</strong></th>
<td style="padding: 5px 8px; text-align: right;">${wagg_samplesPerWindow.toLocaleString()}</td>
</tr>
<tr style="border-bottom: 1px solid var(--bs-border-color, #dee2e6);">
<th scope="row" style="padding: 5px 8px; font-weight: normal; text-align: left;"><strong>Raw Window Size</strong></th>
<td style="padding: 5px 8px; text-align: right;">${wagg_rawBytes >= 1024 ? (wagg_rawBytes/1024).toFixed(1) + " KB" : wagg_rawBytes + " bytes"}</td>
</tr>
<tr style="border-bottom: 1px solid var(--bs-border-color, #dee2e6);">
<th scope="row" style="padding: 5px 8px; font-weight: normal; text-align: left;"><strong>Summary Size</strong> (${wagg_statsFields} fields: min, max, mean, std, count${wagg_includeP95 ? ", p95" : ""})</th>
<td style="padding: 5px 8px; text-align: right; color: #0f6b5c; font-weight: bold;">${wagg_outputBytes} bytes</td>
</tr>
<tr style="border-bottom: 1px solid var(--bs-border-color, #dee2e6);">
<th scope="row" style="padding: 5px 8px; font-weight: normal; text-align: left;"><strong>Compression Ratio</strong></th>
<td style="padding: 5px 8px; text-align: right; color: #8a4a00; font-weight: bold;">${wagg_ratio.toFixed(0)}:1</td>
</tr>
<tr style="border-bottom: 1px solid var(--bs-border-color, #dee2e6);">
<th scope="row" style="padding: 5px 8px; font-weight: normal; text-align: left;"><strong>Summaries per Hour</strong></th>
<td style="padding: 5px 8px; text-align: right;">${wagg_windowsPerHour.toFixed(0)} per sensor</td>
</tr>
</table>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin-top: 1rem;">
<div style="text-align: center; padding: 0.6rem; background: rgba(231,76,60,0.08); border-radius: 6px;">
<div style="font-size: 0.8rem; color: #374151;">Raw Daily (${wagg_sensorCount} sensors)</div>
<div style="font-size: 1.3rem; font-weight: bold; color: #9f1d1d;">${wagg_rawDayMB < 1024 ? wagg_rawDayMB.toFixed(1) + " MB" : (wagg_rawDayMB/1024).toFixed(2) + " GB"}</div>
</div>
<div style="text-align: center; padding: 0.6rem; background: rgba(22,160,133,0.08); border-radius: 6px;">
<div style="font-size: 0.8rem; color: #374151;">Aggregated Daily (${wagg_sensorCount} sensors)</div>
<div style="font-size: 1.3rem; font-weight: bold; color: #0f6b5c;">${wagg_compDayKB < 1024 ? wagg_compDayKB.toFixed(1) + " KB" : (wagg_compDayKB/1024).toFixed(2) + " MB"}</div>
</div>
</div>
<p style="margin-top: 0.8rem; padding: 0.5rem; background: rgba(52,152,219,0.06); border-radius: 4px; font-size: 0.85rem;">
<strong>What's preserved:</strong> Mean (trend tracking), Min/Max (boundary alerts), Std Dev (stability monitoring), Count (data health)${wagg_includeP95 ? ", P95 (tail behavior)" : ""}. <strong>What's lost:</strong> Individual sample timing, exact value sequences, sub-window transient patterns.
</p>
</div>`