Qu

pulse_period

Builtin index · Signal processing

result = pulse_period(x, [level=], [hysteresis=0])

Input: x, level, hysteresis · Output: result

What it is

x: a length-N real vector or Signal; keywords as for find_edges.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = pulse_period(x, [level=], [hysteresis=0])
x vector or Signalx: a length-N real vector or Signal.
level optionalnot documented yet
hysteresis optional (default 0)not documented yet
result number or Signal
Returns a single number: the mean interval between successive rising crossings (pulse_period) or its reciprocal (pulse_frequency) โ€” seconds and Hz for a Signal, samples and cycles/sample otherwise. Errors when the record holds fewer than two rising crossings, i.e. not a full cycle. These are edge-counting measurements; dominant_frequency/estimate_frequency above are spectral estimators answering a different question โ€” see the note before this table.

Examples

No documentation example calls this form yet. The Signal processing chapter is where one belongs.

How it works

pulse_period(x, [level=], [hysteresis=]) / pulse_frequency(x, [level=], [hysteresis=]) -- the mean interval between successive rising crossings, and its reciprocal. Seconds and Hz for a Signal; samples and cycles/sample otherwise. NAMING, since this is the one real collision risk in the cluster. dominant_frequency/estimate_frequency already exist a few hundred lines above and answer a DIFFERENT question by a different method: they take the largest bin of the FFT magnitude spectrum. This one counts edges in the time domain. On a square wave they agree; on anything with a strong harmonic, a DC-ish drift, or a burst that is not periodic over the whole record, they do not, and the failure is silent because both return a plausible Hz. So the bare name frequency (which toolkit-signal.md ยง8 spells) is deliberately NOT taken -- it would be the name a caller reaches for by habit while wanting either one, with nothing at the call site to say which they got. pulse_ says "edge-based, on a pulse train" in the name itself, and pulse_period carries the same prefix for symmetry rather than taking the equally-generic bare period.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.

See also

pulse_frequency — documented in the same entry.