series_floor
This page explains how to use the series_floor function in APL.
The series_floor function rounds down each element in a numeric dynamic array (series) to the nearest integer that’s less than or equal to the original value. This function applies the mathematical floor operation element-wise across the entire array, which is useful for data discretization, quantization, and integer conversion in time series data.
You can use series_floor when you want to convert floating-point values to integers by rounding down, discretize continuous data into bins, or prepare data for categorical analysis. This is particularly useful for creating integer-based categories, implementing quantization schemes, or when you need to ensure values don’t exceed certain thresholds. Typical applications include data binning, performance categorization, and mathematical modeling where integer values are required.
Usage
Syntax
series_floor(array)Parameters
| Parameter | Type | Description |
|---|---|---|
array | dynamic | A dynamic array of numeric values. |
Returns
A dynamic array where each element is the floor (largest integer less than or equal to) the corresponding input element.
Use case examples
In log analysis, you can use series_floor to discretize request durations into integer bins for categorical analysis or performance categorization.
Query
Output
| id | durations | floor_durations |
|---|---|---|
| u123 | [150.7, 200.3, 250.9] | [150, 200, 250] |
| u456 | [100.2, 300.8, 400.1] | [100, 300, 400] |
This query converts floating-point request durations to integers by rounding down, useful for creating discrete performance categories.
In OpenTelemetry traces, you can use series_floor to discretize span durations into integer milliseconds for consistent latency analysis.
Query
Output
| service.name | durations | floor_durations |
|---|---|---|
| frontend | [100.7ms, 200.3ms, 300.9ms] | [100ms, 200ms, 300ms] |
| product-catalog | [50.2ms, 150.8ms, 250.1ms] | [50ms, 150ms, 250ms] |
This query converts floating-point span durations to integer milliseconds by rounding down, useful for consistent latency categorization across services.
In security logs, you can use series_floor to discretize request durations into integer bins for security analysis and attack pattern detection.
Query
Output
| status | durations | floor_durations |
|---|---|---|
| 200 | [150.7, 200.3, 250.9] | [150, 200, 250] |
| 500 | [100.2, 300.8, 400.1] | [100, 300, 400] |
This query converts floating-point request durations to integers by rounding down grouped by status code, useful for creating discrete performance categories in security analysis.
List of related functions
- series_abs: Returns the absolute value of each element in an array. Use when you need to normalize values before applying floor operations.
- series_exp: Calculates the exponential of each element in an array. Use for exponential transformations instead of floor operations.
- series_cos: Returns the cosine of each element in an array. Use for trigonometric transformations instead of floor operations.
- series_sin: Returns the sine of each element in an array. Use for periodic transformations instead of floor operations.
- series_tan: Returns the tangent of each element in an array. Use for trigonometric transformations with different periodicity.