Sliding Window Distinct Count
Count distinct exact-string values in each complete stride-one window, preserving window order.
Description
Count distinct exact-string values in each complete stride-one window, preserving window order.
A sliding distinct count measures local variety within a fixed-width window. Repeated entries contribute once within each window, even when they are nonadjacent.
When to use this tool
Count distinct exact-string values in each complete stride-one window, preserving window order.
- Prepare the supplied values, window fields for this operation.
- Compare the complete example with the representation used by your own input before carrying the result into another step.
How to use the tool and how it works
- Enter values, window. Use the exact text syntax, units and index conventions explained below.
- Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
- Read result.counts. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.
For every complete consecutive window, construct a Set of its values and return the set size in window-start order. Require window from one through 128.1
| Input field | Meaning and representation | Accepted input |
|---|---|---|
| values | values. | At most 128 strings, each at most 128 UTF-16 code units |
| window | window. | Integer from 1 to 128 inclusive |
| Output field | Interpretation |
|---|---|
| result | Object containing the named outputs below. |
| result.counts | The counts list in the ordering and representation described above. |
{
"input": {
"values": [
"a",
"a",
"b",
"a"
],
"window": 3
},
"output": {
"result": {
"counts": [
2,
2
]
}
}
} Limitations and assumptions
- The tool returns counts rather than the distinct members. A window longer than the list produces an empty output; partial windows and locale-aware string comparisons are not used.
- Every declared top-level field is required and unexpected fields are rejected. Numeric inputs must be finite; ordinary text fields are bounded to 8,192 UTF-16 code units, with tighter operation-specific limits where stated.
- Ordinary string lists have at most 128 entries of at most 128 code units each; numeric lists and matrices have separate bounded size checks. Nonfinite results and excessively large serialized outputs are rejected.
- Indexes are zero-based and spans have an exclusive end unless explicitly stated otherwise. A valid false, null or empty-list result is distinct from malformed input.
Alternative or Complementary methods
Use explicit source-index maps when rearranging data or planning missing-value fills. Keep row-major coordinates, cyclic indexes and one-based occurrence numbers distinct, and inspect null donor positions before copying values.
References
Similar or alternative tools
- sliding window
Slice a list into overlapping fixed-size windows stepped one element at a time.
- Sliding Window Transition Count
Count adjacent value transitions in each complete stride-one window, preserving window order.