Sample Grid Endpoint Count
Count a regular sample grid starting at start, with end inclusion explicit; a nonaligned end is not invented as an extra sample.
Description
Count a regular sample grid starting at start, with end inclusion explicit; a nonaligned end is not invented as an extra sample.
Regular sampling places observations at start plus integer multiples of step. An endpoint policy determines the count, but an off-grid endpoint is not an additional sample.
When to use this tool
Count a regular sample grid starting at start, with end inclusion explicit; a nonaligned end is not invented as an extra sample.
- Prepare the supplied start, end, step, includeEnd 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 start, end, step, includeEnd. 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.count, result.lastSample. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.
Require ordered start/end and positive step. Let q equal (end-start)/step. With includeEnd, use floor(q)+1 samples; otherwise use ceil(q). Return the count and final grid value, or null when the count is zero.1
| Input field | Meaning and representation | Accepted input |
|---|---|---|
| start | start. | Finite number |
| end | end. | Finite number |
| step | step. | Finite number; greater than zero |
| includeEnd | Explicit choice for include end; supply a boolean rather than a text label. | true or false |
| Output field | Interpretation |
|---|---|
| result | Object containing the named outputs below. |
| result.count | The count value under the stated formula or text convention. |
| result.lastSample | The last sample value under the stated formula or text convention. |
{
"input": {
"start": 0,
"end": 4,
"step": 2,
"includeEnd": true
},
"output": {
"result": {
"count": 3,
"lastSample": 4
}
}
} Limitations and assumptions
- includeEnd permits a grid point exactly at end; it does not append end when off grid. The grid is bounded and uses floating-point arithmetic without a rounding tolerance.
- 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
Choose a sampling model before combining results. Earlier-sample hold, linear interpolation and index-only differences answer different questions; event cooldown, debounce and rolling limits also use different acceptance rules.
References
Similar or alternative tools
- Sample First Difference Signs
Return signs of adjacent sampled first differences, preserving flat steps as zero.
- Sample Hold Expander
Evaluate previous-sample hold at explicit query times within the sampled domain; exact sample timestamps use their new value.