Skip to content

Arbitrary[Double] distribution is borken #113

@benhutchison

Description

@benhutchison

Scalacheck is using a flawed method [https://github.com/rickynils/scalacheck/blob/master/src/main/scala/org/scalacheck/Arbitrary.scala#L105] to generate Arbitrary Double values. Currently, it basically generates 3 number "archetypes": +1E307, 0.0, and -1E307. Because it is using a uniform distribution with endpoints at +/- E307, the chance of it generating any values in a everyday range (say +/- 1000) is infinitesimally small.

A good solution IMO is to use a log-uniform distribution, ie one where log(value) is uniformly distributed, not the values themselves. This can be done by generating the mantissa and the exponent separately from uniform distributions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions