nk 1.0.0
C++ Numerical Computing Runtime
Loading...
Searching...
No Matches

Moving / sliding-window statistics over a 1-D / N-D array. More...

#include <memory_resource>
#include <nk/value/span.hpp>
#include <nk/value/value.hpp>
#include <string>

Go to the source code of this file.

Functions

Value nk::stats::movmean (const Value &x, Span< const size_t > k, int dim=0, std::pmr::memory_resource *mr=nullptr)
 Moving mean along dim (y = movmean(x, k)).
Value nk::stats::movmedian (const Value &x, Span< const size_t > k, int dim=0, std::pmr::memory_resource *mr=nullptr)
 Moving median along dim (y = movmedian(x, k)).
Value nk::stats::movsum (const Value &x, Span< const size_t > k, int dim=0, std::pmr::memory_resource *mr=nullptr)
 Moving sum along dim (y = movsum(x, k)).
Value nk::stats::movmin (const Value &x, Span< const size_t > k, int dim=0, std::pmr::memory_resource *mr=nullptr)
 Moving minimum along dim (y = movmin(x, k)).
Value nk::stats::movmax (const Value &x, Span< const size_t > k, int dim=0, std::pmr::memory_resource *mr=nullptr)
 Moving maximum along dim (y = movmax(x, k)).
Value nk::stats::movstd (const Value &x, Span< const size_t > k, int normFlag=0, int dim=0, std::pmr::memory_resource *mr=nullptr)
 Moving standard deviation along dim (y = movstd(x, k, normFlag)).
Value nk::stats::movvar (const Value &x, Span< const size_t > k, int normFlag=0, int dim=0, std::pmr::memory_resource *mr=nullptr)
 Moving variance along dim (y = movvar(x, k, normFlag)).
Value nk::stats::movmad (const Value &x, Span< const size_t > k, int dim=0, std::pmr::memory_resource *mr=nullptr)
 Moving mean absolute deviation (y = movmad(x, k)).
Value nk::stats::movprod (const Value &x, Span< const size_t > k, int dim=0, std::pmr::memory_resource *mr=nullptr)
 Moving product along dim (y = movprod(x, k)).
Value nk::stats::smoothdata (const Value &x, const std::string &method="movmean", int k=0, int dim=0, std::pmr::memory_resource *mr=nullptr)
 Method-dispatching data smoother (y = smoothdata(x, method, k)).
Value nk::stats::hampel (const Value &x, int k=3, double nsigmas=3.0, std::pmr::memory_resource *mr=nullptr)
 Hampel outlier-resilient median filter (y = hampel(x, k, nsigmas)).

Detailed Description

Moving / sliding-window statistics over a 1-D / N-D array.

Window descriptor k (shared by all mov* functions):

  • 1-element span {k} → centred window of length k: kb = floor((k-1)/2) leading samples, kf = floor(k/2) trailing
  • 2-element span {kb, kf} → asymmetric window covering [i-kb, i+kf]

Endpoints are NOT discarded — the window truncates at the edges ('shrink' is the default). Windows that become empty after truncation produce NaN.

Dimension argument dim:

  • dim == 0 → operate along the first non-singleton dim (auto)
  • dim >= 1 → operate along that 1-based dim. Vector / scalar inputs ignore dim.

Definition in file moving.hpp.