Closed wathiede closed 11 years ago
Wow. Great find. I'm sorry I didn't notice it. Will fix.
It was an off by one error, of course.
Hmm, I think there is a new problem now. Running the modified example in my original comment yields this:
$ go run ex.go
panic: runtime error: index out of range
goroutine 1 [running]:
github.com/bmizerany/perks/quantile.(*Stream).Query(0x4c2000580e0, 0x3fe0000000000000, 0x3fe2cb25a0ca16c6)
/-snip-/Go/src/github.com/bmizerany/perks/quantile/stream.go:112 +0x83
main.main()
/-snip-/Go/src/q/ex.go:27 +0x14a
goroutine 3 [chan send]:
main.readFloats(0x4c200069000)
/-snip-/Go/src/q/ex.go:12 +0x4e
created by main.main
/-snip/Go/src/q/ex.go:19 +0x58
With line 27:
fmt.Println("perc50:", q.Query(0.50))
Which is the first Query call after the the first insert.
Yeah. On it.
On Tue, Apr 16, 2013 at 1:03 PM, wathiede notifications@github.com wrote:
Hmm, I think there is a new problem now. Running the modified example in my original comment yields this:
$ go run ex.go panic: runtime error: index out of range
goroutine 1 [running]:github.com/bmizerany/perks/quantile.(*Stream).Query(0x4c2000580e0, 0x3fe0000000000000, 0x3fe2cb25a0ca16c6) /-snip-/Go/src/github.com/bmizerany/perks/quantile/stream.go:112 +0x83 main.main() /-snip-/Go/src/q/ex.go:27 +0x14a
goroutine 3 [chan send]: main.readFloats(0x4c200069000) /-snip-/Go/src/q/ex.go:12 +0x4e created by main.main /-snip/Go/src/q/ex.go:19 +0x58
With line 27:
fmt.Println("perc50:", q.Query(0.50))
Which is the first Query call after the the first insert.
— Reply to this email directly or view it on GitHubhttps://github.com/bmizerany/perks/issues/1#issuecomment-16468316 .
@wathiede This should do it. Thank you for the submission and example.
Also, I fixed the examples when I noticed your example giving 0.01 as the first parameter to NewTargeted, which was an old, pre-OSS API.
Yay, thanks!
Np. Sorry for such an embarrassing bug. :/
On Tue, Apr 16, 2013 at 7:09 PM, wathiede notifications@github.com wrote:
Yay, thanks!
— Reply to this email directly or view it on GitHubhttps://github.com/bmizerany/perks/issues/1#issuecomment-16483157 .
Using the slightly modified code from 'Example (Simple)' (see below), I get the following output:
It appears that q.Count() et. al. don't return valid data until the first flush and compress. Not sure if this is obvious to someone who better understands the Biased Quantiles paper, and it is a problem that fixes itself with more samples, but it was a bit surprising to me while experimenting with the library.