Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Improve quality of integer output #18

Open
Fresheyeball opened this issue Sep 4, 2015 · 2 comments
Open

Improve quality of integer output #18

Fresheyeball opened this issue Sep 4, 2015 · 2 comments

Comments

@Fresheyeball
Copy link

This code:

func TestFoo(t *testing.T) {
    var i int
    fuzzy := fuzz.New()
    forN(100, func() {
        fuzzy.Fuzz(&i)
        log.Println(i)
    })
}

produces:

2015/09/04 12:35:09 -7835246273949666689
2015/09/04 12:35:09 -3335834746906823390
2015/09/04 12:35:09 -797614582871569465
2015/09/04 12:35:09 -1880490989454751177
2015/09/04 12:35:09 8642978877542446388
2015/09/04 12:35:09 7210419396307716596
2015/09/04 12:35:09 -1013781862395183072
2015/09/04 12:35:09 -6870665591055426828
2015/09/04 12:35:09 7613138460266199146
2015/09/04 12:35:09 -5153746402492891673
2015/09/04 12:35:09 810562363728706214
2015/09/04 12:35:09 -6642518234775288016
2015/09/04 12:35:09 -2591875516334598574
2015/09/04 12:35:09 -8510913015654777828
2015/09/04 12:35:09 4315878390670269427
2015/09/04 12:35:09 4755147220257554544
2015/09/04 12:35:09 -595777994041846809
2015/09/04 12:35:09 -3921103541046646506
2015/09/04 12:35:09 -2687620294811223767
2015/09/04 12:35:09 59623211572459200
2015/09/04 12:35:09 580834844145044863
2015/09/04 12:35:09 -7587201369927064342
2015/09/04 12:35:09 -8485154379888275139
2015/09/04 12:35:09 4417374548573622764
2015/09/04 12:35:09 -720185865975215166

Looks like ints never come out with an absolute value lower than one septillion, which is undesirable. I'd like to see an option to guarantee at-least one instance of zero as well.

@lavalamp
Copy link
Contributor

lavalamp commented Sep 4, 2015

That's a really good point. Maybe an exponential distribution would be better than a uniform distribution.

@Fresheyeball
Copy link
Author

👍 for exponential

Think about this more, there are further special values other than 0 I'd like the ability to guarantee, like the primes...

I think the ideal is to use Perturbation in the generation of values across the library, rather than simple distributions like uniform and exponential.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants