-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigate floating generation #172
Merged
Merged
+179
−88
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lehins
changed the title
Lehins/investigate floating generation
Investigate floating generation
Dec 23, 2024
lehins
force-pushed
the
lehins/investigate-floating-generation
branch
5 times, most recently
from
December 25, 2024 21:23
8d53061
to
817fd1f
Compare
Shimuuar
reviewed
Dec 25, 2024
lehins
force-pushed
the
lehins/investigate-floating-generation
branch
2 times, most recently
from
December 25, 2024 22:34
940ade6
to
89b17ed
Compare
lehins
force-pushed
the
lehins/investigate-floating-generation
branch
from
December 26, 2024 00:49
36ea4dd
to
7475561
Compare
Flupp
reviewed
Dec 26, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some nits I noticed while looking at the current solution.
These benchamrks help us better compare `uniformRM` performance to `uniformFloat01M`/`uniformDouble01M`
Leaving a thunk around for the computed floating point value leads to a significant performance degradation when generating many floating point values and also lead to low and high range values being retained in memory for longer than necessary.
In order to avoid strange cases and improve floating point randomness the way that floating point values are generated and scaled to a custom range has been improved.
lehins
force-pushed
the
lehins/investigate-floating-generation
branch
from
December 27, 2024 16:45
7475561
to
dc15de7
Compare
netbsd-srcmastr
pushed a commit
to NetBSD/pkgsrc
that referenced
this pull request
Jan 29, 2025
# 1.3.0 * Improve floating point value generation and avoid degenerate cases: [#172](haskell/random#172) * Add `Uniform` instance for `Maybe` and `Either`: [#167](haskell/random#167) * Add `Seed`, `SeedGen`, `seedSize`, `seedSizeProxy`, `mkSeed` and `unSeed`: [#162](haskell/random#162) * Add `mkSeedFromByteString`, `unSeedToByteString`, `withSeed`, `withSeedM`, `withSeedFile`, `seedGenTypeName`, `nonEmptyToSeed`, `nonEmptyFromSeed`, `withSeedM`, `withSeedMutableGen` and `withSeedMutableGen_` * Add `SplitGen` and `splitGen`: [#160](haskell/random#160) * Add `unifromShuffleList` and `unifromShuffleListM`: [#140](haskell/random#140) * Add `uniformWordR`: [#140](haskell/random#140) * Add `mkStdGen64`: [#155](haskell/random#155) * Add `uniformListRM`, `uniformList`, `uniformListR`, `uniforms` and `uniformRs`: [#154](haskell/random#154) * Add compatibility with recently added `ByteArray` to `base`: [#153](haskell/random#153) * Switch to using `ByteArray` for type class implementation instead of `ShortByteString` * Add `unsafeUniformFillMutableByteArray` to `RandomGen` and a helper function `defaultUnsafeUniformFillMutableByteArray` that makes implementation for most instances easier. * Add `uniformByteArray`, `uniformByteString` and `uniformFillMutableByteArray` * Deprecate `genByteString` in favor of `uniformByteString` * Add `uniformByteArrayM` to `StatefulGen` * Add `uniformByteStringM` and `uniformShortByteStringM` * Deprecate `System.Random.Stateful.uniformShortByteString` in favor of `uniformShortByteStringM` for consistent naming and a future plan of removing it from `StatefulGen` type class * Add a pure `System.Random.uniformShortByteString` generating function. * Deprecate `genShortByteString` in favor of `System.Random.uniformShortByteString` * Expose a helper function `fillByteArrayST`, that can be used for defining implementation for `uniformByteArrayM` * Deprecate `genShortByteStringST` and `genShortByteStringIO` in favor of `fillByteArrayST` * Improve `FrozenGen` interface: [#149](haskell/random#149) * Move `thawGen` from `FreezeGen` into the new `ThawGen` type class. Fixes an issue with an unlawful instance of `StateGen` for `FreezeGen`. * Add `modifyGen` and `overwriteGen` to the `FrozenGen` type class * Switch `splitGenM` to use `SplitGen` and `FrozenGen` instead of deprecated `RandomGenM` * Add `splitMutableGenM` * Switch `randomM` and `randomRM` to use `FrozenGen` instead of `RandomGenM` * Deprecate `RandomGenM` in favor of a more powerful `FrozenGen` * Add `isInRangeOrd` and `isInRangeEnum` that can be used for implementing `isInRange`: [#148](haskell/random#148) * Add `isInRange` to `UniformRange`: [#78](haskell/random#78) * Add default implementation for `uniformRM` using `Generics`: [#92](haskell/random#92)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR applies suggestion from and resolves #166
It also fixes #53
It also makes the result of
uniformRM
on floating point numbers strict, since there is a huge performance penalty for keeping the result lazy