series_dot_product function calculates the dot product between two dynamic arrays (series) of numeric values. The dot product is computed by multiplying corresponding elements from both arrays and then summing all the products. This mathematical operation is fundamental in linear algebra and is useful for measuring similarity, calculating projections, and performing various analytical computations on time-series data.
You can use series_dot_product when you need to measure the similarity between two datasets, calculate weighted sums, perform correlation analysis, or compute projections in multidimensional analysis. Common applications include recommendation systems, signal processing, pattern recognition, and statistical analysis of performance metrics.
For users of other query languages
If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.Splunk SPL users
Splunk SPL users
In Splunk SPL, calculating dot products requires complex operations using
eval commands with array manipulation and mathematical functions. In APL, series_dot_product provides this calculation directly for dynamic arrays.ANSI SQL users
ANSI SQL users
In SQL, calculating dot products requires joining arrays, multiplying corresponding elements, and summing the results. This typically involves complex window functions and mathematical operations. In APL,
series_dot_product handles this calculation directly on dynamic arrays.Usage
Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
array1 | dynamic | The first dynamic array of numeric values. |
array2 | dynamic | The second dynamic array of numeric values. |
Returns
Areal value representing the dot product of the two arrays. If the arrays have different lengths, only elements up to the length of the shorter array are used in the calculation.
Use case examples
- Log analysis
- OpenTelemetry traces
- Security logs
In log analysis, you can use Run in PlaygroundOutput
This query calculates weighted activity scores by computing the dot product of request counts and duration-based importance weights.
series_dot_product to calculate weighted similarity scores between user request patterns, where weights represent the importance of different time periods.Query| id | request_counts | importance_weights | weighted_score |
|---|---|---|---|
| u123 | [1, 1, 1] | [1.2, 3.4, 0.8] | 5.4 |
| u456 | [1, 1] | [2.1, 1.5] | 3.6 |
List of related functions
- series_abs: Returns the absolute value of each element in an array. Use when you need to remove negative signs without rounding.
- series_add: Performs element-wise addition between two arrays. Use when you need to combine values instead of calculating ratios.
- series_cosine_similarity: Calculates cosine similarity between two arrays. Use when you need normalized similarity measures rather than raw dot products.
- series_divide: Performs element-wise division between two arrays. Use when you need to calculate ratios or normalize values.
- series_sum: Calculates the sum of all elements in a single array. Use when you need to sum elements within one array rather than computing dot products.