robojeb / pcg_rand Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
It would be nice to have CI integration to run build and tests.
I'm working on updating pcg_rand
to use rand_core
0.2 (which corresponds to Rand 0.5) instead of Rand 0.4. Unfortunately, I ran into a compiler bug (rust-lang/rust#43408). I'm not sure yet how to work around it.
Here's a program:
extern crate rand;
extern crate pcg_rand;
use rand::Rng;
use rand::XorShiftRng;
use pcg_rand::Pcg32;
pub fn main() {
let mut xorshift = XorShiftRng::new_unseeded();
let mut pcg = Pcg32::new_unseeded();
let xv: u32 = xorshift.gen();
let pv: u32 = pcg.gen();
println!("{} {}", xv, pv);
}
And here's its output (at least on my box):
3690029583 0
While the pcg
output is technically ok โ the generator is unseeded, and so can start the sequence where it likes โ I'd strongly prefer that the first output of an unseeded generator still "look random" as with xorshift
. Fix should be as easy as a call to gen()
inside new_unseeded()
.
About a month ago I started implementing the PCG extension mechanism in a repository where I compare small RNG's. But when I realized how complex it was it did not seem like a good fit.
I you are still interested in working on the extension mechanism, it may be a good starting point:
https://github.com/pitdicker/small-rngs/blob/master/src/pcg_ext.rs
And an overview of how I think it is supposed to work: dhardy/rand#52 (comment)
886f854 added a #![feature(tool_lints)]
which requires nightly to work, making it not possible to use 0.9.2 on beta or stable
Line 121 in 93ff7d3
The tool_lints
warning has been canceled by rust-lang/rust#54358 on the current 1.30 beta channel, so writing #[allow(needless_pass_by_value)]
should be fine.
BTW, the feature has been stabilized by rust-lang/rust#54870 on the current 1.31 nightly channel meaning you don't need #![feature(tool_lints)]
to write #[allow(clippy::needless_pass_by_value)]
either.
u128
and i128
were added in rust-lang/rust/pull/38482. They're currently behind the i128_type
feature gate.
How can I access and save the state in a way, that I can resume the pseudo random number generator at a later time?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.