https://github.com/lemire/swiftwyhash
Fast random number generator in pure Swift
https://github.com/lemire/swiftwyhash
Last synced: 5 months ago
JSON representation
Fast random number generator in pure Swift
- Host: GitHub
- URL: https://github.com/lemire/swiftwyhash
- Owner: lemire
- License: apache-2.0
- Created: 2019-05-28T17:02:48.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2025-05-26T19:51:39.000Z (about 1 year ago)
- Last Synced: 2025-09-17T19:37:07.179Z (10 months ago)
- Language: Swift
- Size: 28.3 KB
- Stars: 25
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
README
# SwiftWyhash
This is Swift port of pseudorandom number generator `wyrand` from [wyhash](https://github.com/wangyi-fudan/wyhash) by Wang Yi. On 64-bit hardware, it is should be effectively faster than any other commonly available random number generator. It meets quality standards: it passes Big Crunch.
It conforms to [RandomNumberGenerator](https://developer.apple.com/documentation/swift/randomnumbergenerator) protocol.
Usage:
```swift
var gen = WyRand(seed: 42)
gen.next() // generates a 64-bit random number
(1...10).shuffled(using: &gen)
```
For a benchmark, see [SwiftWyhashBenchmark](https://github.com/lemire/SwiftWyhashBenchmark).
Further reading: [The fastest conventional random number generator that can pass Big Crush?](https://lemire.me/blog/2019/03/19/the-fastest-conventional-random-number-generator-that-can-pass-big-crush/)