Skip to content

Help biasing infinite stream of integers towards small values #3545

Answered by dubzzz
dball asked this question in Q&A
Discussion options

You must be logged in to vote

Hey,

Actually today the combination of fc.infiniteStream and fc.nat can be considered as biased as it generates much more small numbers than what it should if the values was taken fully randomly:

But the problem is that there is, at the moment, no bias all the values of this stream. In other words, in the current version of fast-check, while values produced by the generators of natural number can be biased from time to time, they are:

  1. Never biased for some streams
  2. Not biased for all entries

In the current versions the trick I'd suggest is to do something like:

fc.oneof(
  fc.infiniteStream(fc.nat({max: 10})),
  fc.infiniteStream(fc.nat())
)

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@dubzzz
Comment options

@dball
Comment options

@dubzzz
Comment options

Answer selected by dball
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants