From 49c9664118f9e9e8311ecec9b275d1b34893674d Mon Sep 17 00:00:00 2001 From: yha Date: Wed, 22 Jun 2022 02:06:25 +0300 Subject: [PATCH] docs --- src/RunningQuantiles.jl | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/RunningQuantiles.jl b/src/RunningQuantiles.jl index 7aa8bf1..302f47c 100644 --- a/src/RunningQuantiles.jl +++ b/src/RunningQuantiles.jl @@ -28,14 +28,31 @@ function make_window(winlen::Int) -winlen÷2:winlen÷2 end + +""" + running_median(v, w, nan_mode=SkipNaNs()) + +Computes the running median of the vector `v` with window `w`, where `w` is an odd window length, or a range of offsets. +See [`running_quantile`](@ref) for details. +""" function running_median(v, w, nan_mode=SkipNaNs(); buffer = default_buffer(v,0.5,w)) running_quantile(v, 0.5, w, nan_mode; buffer) end +""" + result = running_quantile(v, p, w, nan_mode=SkipNaNs()) + +Computes the running `p`-th quantile of the vector `v` with window `w`, where `w` is an odd window length, or a range of offsets. +Specifically, + - if `w` is a `AbstractUnitRange`, `result[i]` is the `p`-th quantile of `v[(i .+ w) ∩ eachindex(v)]`, where `NaN`s are handled according to `nan_mode`: + - `nan_mode==SkipNaN()`: `NaN` values are ignored; quantile is computed over non-`NaN`s + - `nan_mode==PropagateNaNs()`: the result is `NaN` whenever the input window contains `NaN` + - `nan_mode==ErrOnNaN()`: an error is raise if at least one input window contains `NaN` + - if `w` is an odd integer, a centered window of length `w` is used, namely `-w÷2:w÷2` + """ function running_quantile(v, p, w, nan_mode=SkipNaNs(); buffer = default_buffer(v,p,w)) _running_quantile(v, p, make_window(w), nan_mode; buffer) end - function _running_quantile(v, p, r::AbstractUnitRange, nan_mode; buffer) result = similar(v, float(eltype(v))) # wrapping this Int in a `Ref` helps the compiler not create a `Box`