Skip to contents

The method is the closed-form Gaussian Kullback-Leibler divergence between the two windows; its usual attribution ("Gulenko et al 2019") matches no traceable paper on density-shift detection and is not relied on. KL is not symmetric, and is zero exactly when the two windows agree; both are checked.

Usage

Gpdsh(y_stream, window = 10, tau = 0.5, floor = 1e-12)

Arguments

y_stream

Numeric stream.

window

Window length, at least 2.

tau

Threshold above which a shift is declared.

floor

Lower bound on a window variance.

Value

List with estimate, kl, flagged, position, max_kl, change_point, n_shifts, n, method.

Details

Formula: KL(p || q) = log(s_q/s_p) + (s_p^2 + (m_p - m_q)^2)/(2 s_q^2) - 1/2.

References

Kullback and Leibler (1951), On information and sufficiency, Annals of Mathematical Statistics 22(1):79-86. doi:10.1214/aoms/1177729694

Examples

set.seed(1)
Gpdsh(rnorm(30), window = 10)
#> $estimate
#> [1] 0.1348957
#> 
#> $kl
#>  [1] 0.134895690 0.054141118 0.058720240 0.050222988 0.059898473 0.055140487
#>  [7] 0.032356117 0.033120031 0.009702062 0.042906142 0.075739736
#> 
#> $flagged
#>  [1] 0 0 0 0 0 0 0 0 0 0 0
#> 
#> $position
#>  [1] 10 11 12 13 14 15 16 17 18 19 20
#> 
#> $max_kl
#> [1] 0.1348957
#> 
#> $change_point
#> [1] 10
#> 
#> $n_shifts
#> [1] 0
#> 
#> $n
#> [1] 30
#> 
#> $method
#> [1] "Gaussian KL between consecutive windows against tau; attribution 'Gulenko et al (2019)' UNVERIFIED"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"