Skip to content

Commit fa41350

Browse files
author
Micah Parks
committed
Update README.md
1 parent 325dc99 commit fa41350

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,40 @@ coverage: 100.0% of statements
103103
ok github.com/MicahParks/peakdetect 0.019s
104104
```
105105

106+
# Performance
107+
To further improve performance, this algorithm uses Welford's algorithm on initialization
108+
and an adaptation of [this StackOverflow answer](https://stackoverflow.com/a/14638138/14797322) to calculate the mean
109+
and population standard deviation for the lag period (sliding window). This appears to improve performance by more than
110+
a factor of 10!
111+
112+
`v0.0.4`
113+
```
114+
goos: linux
115+
goarch: amd64
116+
pkg: github.com/MicahParks/peakdetect
117+
cpu: Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
118+
BenchmarkPeakDetector_NextBatch
119+
BenchmarkPeakDetector_NextBatch-6 1000000000 0.0000278 ns/op
120+
PASS
121+
```
122+
123+
`v0.0.5`
124+
```
125+
goos: linux
126+
goarch: amd64
127+
pkg: github.com/MicahParks/peakdetect
128+
cpu: Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
129+
BenchmarkPeakDetector_NextBatch-6 1000000000 0.0000013 ns/op
130+
PASS
131+
ok github.com/MicahParks/peakdetect 0.002s
132+
```
133+
106134
# References
107135
Brakel, J.P.G. van (2014). "Robust peak detection algorithm using z-scores". Stack Overflow. Available
108136
at: https://stackoverflow.com/questions/22583391/peak-signal-detection-in-realtime-timeseries-data/22640362#22640362
109137
(version: 2020-11-08).
138+
139+
* [StackOverflow: Peak detection in realtime timeseries data](https://stackoverflow.com/a/22640362/14797322).
140+
* [StackOverflow: sliding window for online algorithm to calculate mean and standard devation](https://stackoverflow.com/a/14637676/14797322)
141+
* [Welford's algorithm related blog post](https://www.johndcook.com/blog/standard_deviation/).
142+
* Yeah, I used [Wikipedia](https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance) too.

0 commit comments

Comments
 (0)