netwire-2.0.1: Generic automaton arrow transformer and useful tools

Maintainer Ertugrul Soeylemez

Control.Wire.Prefab.Analyze

Contents

Description

Various signal analysis tools

Synopsis

# Statistics

## Average

avg :: forall e v (>~). (Arrow >~, Fractional v, Unbox v) => Int -> Wire e >~ v vSource

Calculate the average of the signal over the given number of last samples. If you need an average over all samples ever produced, consider using `avgAll` instead.

• Complexity: O(n) space, O(1) time wrt number of samples.
• Depends: current instant.

avgAll :: forall e v (>~). (Arrow >~, Fractional v) => Wire e >~ v vSource

Calculate the average of the signal over all samples.

Please note that somewhat surprisingly this wire runs in constant space and is generally faster than `avg`, but most applications will benefit from averages over only the last few samples.

• Depends: current instant.

avgFps :: (ArrowChoice >~, ArrowClock >~, Fractional t, Time >~ ~ t, Unbox t) => Int -> Wire e >~ a tSource

Calculate the average number of frames per virtual second for the last given number of frames.

Please note that this wire uses the clock from the `ArrowClock` instance for the underlying arrow. If this clock doesn't represent real time, then the output of this wire won't either.

## Peak

highPeak :: Ord b => Wire e >~ b bSource

Outputs the high peak of the input signal.

• Depends: Current instant.

lowPeak :: Ord b => Wire e >~ b bSource

Outputs the low peak of the input signal.

• Depends: Current instant.

peakBy :: forall b e (>~). (b -> b -> Ordering) -> Wire e >~ b bSource

Outputs the high peak of the input signal with respect to the given comparison function.

• Depends: Current instant.

# Monitoring

collect :: forall b e (>~). Ord b => Wire e >~ b (Set b)Source

Collects all distinct inputs ever received.

• Complexity: O(n) space, O(log n) time wrt collected inputs so far.
• Depends: current instant.

diff :: forall b e (>~). (Eq b, Monoid e) => Wire e >~ b bSource

Outputs the last input value on every change of the input signal. Acts like the identity wire at the first instant.

• Depends: current instant.
• Inhibits: on no change after the first instant.

firstSeen :: forall a e t (>~). (ArrowChoice >~, ArrowClock >~, Monoid e, Ord a, Time >~ ~ t) => Wire e >~ a tSource

Reports the first time the given input was seen.

• Complexity: O(n) space, O(log n) time wrt collected inputs so far.
• Depends: Current instant.

lastSeen :: forall a e t (>~). (ArrowClock >~, Monoid e, Ord a, Time >~ ~ t) => Wire e >~ a tSource

Reports the last time the given input was seen. Inhibits when seeing a signal for the first time.

• Complexity: O(n) space, O(log n) time wrt collected inputs so far.
• Depends: Current instant.
• Inhibits: On first sight of a signal.