Closed pnevyk closed 1 year ago
It depends. The main goal of fastrand
is to be a small, efficient RNG library. I don't want it to get too bloated.
I'm wondering if it would be better to create a fastrand-contrib
crate with all of these extra functions, which can probably be implemented in terms of fastrand
's current API.
The main goal of fastrand is to be a small, efficient RNG library. I don't want it to get too bloated.
Yeah, I thought so and I am in favor of that. Although I was thinking only about uniform and normal distributions, if the crate introduced those, anyone could then ask for more, so probably better to not give a precedent.
A separate crate makes sense to me. In the end, it is what rand
crate also has in form of rand_distr. I am fine with making the implementations, but I assume you (smol-rs
) would like to be the owner of such a crate?
I've created the new fastrand-contrib
repository, not yet finished or published yet. Over the next month or so I'll spruce it up and publish it to crates.io.
Great, thank you! Should I provide the implementations for f{32,64}_range
and f{32,64}_normal
(or any other name), perhaps as a PR to the new repo, or do you want to do it yourself? Naive f{32,64}_range
is trivial, but there are techniques that work even if max - min
overflows the float's max value. For normal distribution sampling I use Box-Muller transform.
Go ahead and make a PR, I'll review and accept it.
This is now exposed in fastrand-contrib
v0.1.0.
Hi,
What do you think about adding APIs for generating values from uniform and normal distributions? I personally think that these two are so common and generally useful that it might be worthy to add them into the crate. Uniform distribution is essentially the same as hypothetical
{f32,f64}_range
functions mentioned in #18.If this feature is acceptable, I would gladly submit a PR.