series_stats_dynamic
This page explains how to use the series_stats_dynamic function in APL.
The series_stats_dynamic function computes comprehensive statistical measures for a numeric dynamic array (series), returning results in a dynamic object format with named properties. This provides the same statistics as series_stats but with more convenient access through property names instead of array indices.
You can use series_stats_dynamic when you need statistical summaries with easier property-based access, better code readability, or when integrating with other dynamic data structures. This is particularly useful in complex analytical workflows where referring to statistics by name (stats.min, stats.avg) is clearer than using array indices.
Usage
Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
array | dynamic | A dynamic array of numeric values. |
Returns
A dynamic object containing the following statistical properties:
| Property | Description |
|---|---|
min | The minimum value in the input array. |
min_idx | The first position of the minimum value in the array. |
max | The maximum value in the input array. |
max_idx | The first position of the maximum value in the array. |
avg | The average value of the input array. |
variance | The sample variance of the input array. |
stdev | The sample standard deviation of the input array. |
Use case examples
In log analysis, you can use series_stats_dynamic to generate comprehensive statistical reports with readable property names.
Query
Output
| id | min | max | avg | performance_score |
|---|---|---|---|---|
| u123 | 15 | 245 | 95 | 52.4 |
| u456 | 8 | 189 | 78 | 50.4 |
This query uses property names to access statistics and calculate a custom performance score based on the coefficient of variation.
In security logs, you can use series_stats_dynamic to build adaptive anomaly detection thresholds with clear, self-documenting property access.
Query
Output
| status | avg_duration | stdev | lower_bound | upper_bound | range_ratio |
|---|---|---|---|---|---|
| 200 | 52 | 12.5 | 27 | 77 | 6.44 |
| 401 | 450 | 850.2 | -1250.4 | 2150.4 | 19.68 |
| 500 | 125 | 95.3 | -65.6 | 315.6 | 4.36 |
This query uses named properties to calculate confidence intervals and assess the relative range of values for adaptive security monitoring.
List of related functions
- series_stats: Returns the same statistics as a 7-element array instead of a dynamic object with named properties.
- series_max: Compares two arrays element-wise and returns the maximum values.
- series_min: Compares two arrays element-wise and returns the minimum values.
- todynamic: Converts values to dynamic type for custom object construction.