-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Swap loops and improve segmented analysis (#57)
* swap loops and improve segmented analysis * non-computed metrics: NaN instead of Inf
- Loading branch information
1 parent
286cf5d
commit 971564b
Showing
3 changed files
with
190 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using TransitionsInTimeseries | ||
|
||
n = 10_000 | ||
t = 1:n | ||
x = rand(n) | ||
indicators = (var, ar1_whitenoise) | ||
change_metrics = RidgeRegressionSlope() | ||
config = SlidingWindowConfig(indicators, change_metrics, stride_ind = 2, stride_cha = 10) | ||
results = estimate_indicator_changes(config, x, t) | ||
signif = SurrogatesSignificance() | ||
@btime significant_transitions($results, $signif) | ||
#= | ||
New code = swaploops-indicators-surrogates. | ||
Old code = main branch (2023/10/30). | ||
New code: 2.103 s (60,345 allocations: 1.12 GiB) | ||
Old code: 2.413 s (80,415 allocations: 2.24 GiB) | ||
=# | ||
|
||
|
||
|
||
nseg = 10 | ||
tseg_start = 100 .+ range(0, 0.9 * n, length = nseg) | ||
tseg_end = 900 .+ range(0, 0.9 * n, length = nseg) | ||
config = SegmentedWindowConfig(indicators, change_metrics, collect(tseg_start), | ||
collect(tseg_end), min_width_cha = 50) | ||
results = estimate_indicator_changes(config, x, t) | ||
flags = significant_transitions(results, signif) | ||
@btime significant_transitions($results, $signif) | ||
#= | ||
New code = swaploops-indicators-surrogates. | ||
Old code = main branch (2023/10/30). | ||
New code: 3.024 s (202,536 allocations: 956.14 MiB) | ||
Old code: 3.881 s (403,763 allocations: 1.87 GiB) | ||
=# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.