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

Cookbook ideas for the rand crate #227

Closed
brson opened this Issue Jul 8, 2017 · 5 comments

Comments

Projects
None yet
5 participants
@brson
Contributor

brson commented Jul 8, 2017

We already have 4 examples:

So it's not obvious we need more. But here's an opportunity to reevaluate the set we've got and brainstorm about it.

@brson brson added the tracking issue label Jul 8, 2017

@Phaiax

This comment has been minimized.

Show comment
Hide comment
@Phaiax

Phaiax Jul 13, 2017

Contributor

Similar to the range example: Create random passwords from a set of allowed characters.

Contributor

Phaiax commented Jul 13, 2017

Similar to the range example: Create random passwords from a set of allowed characters.

@convoliution

This comment has been minimized.

Show comment
Hide comment
@convoliution

convoliution Oct 27, 2017

Contributor

How about an example of creating a specified-length vector of random numbers out of rng.gen_iter()?

edit: I realize a bit late that with the current rand API, it might be more practical to push values into the vector in a for loop, especially if you need a particular range or distribution.

Contributor

convoliution commented Oct 27, 2017

How about an example of creating a specified-length vector of random numbers out of rng.gen_iter()?

edit: I realize a bit late that with the current rand API, it might be more practical to push values into the vector in a for loop, especially if you need a particular range or distribution.

@budziq

This comment has been minimized.

Show comment
Hide comment
@budziq

budziq Oct 30, 2017

Collaborator

@mykalu

it might be more practical to push values into the vector in a for loop, expecially if you need a particular range or distribution

Fair points. To be honest rand requires a major rewrite to make it really pleasant to use.
It all depends on what the user needs, (ie. If they do not care about the distribution) then gen_iter approach might be viable. If one despises for loops one can always build custom iterator (~4-5 additional lines) or use hacky range mapping approach ;)

    let mut rng = rand::thread_rng();
    // mean 2, standard deviation 3:
    let normal = Normal::new(2.0, 3.0);
    let v: Vec<_> = (0..10).map(|_| normal.ind_sample(&mut rng)).collect();
Collaborator

budziq commented Oct 30, 2017

@mykalu

it might be more practical to push values into the vector in a for loop, expecially if you need a particular range or distribution

Fair points. To be honest rand requires a major rewrite to make it really pleasant to use.
It all depends on what the user needs, (ie. If they do not care about the distribution) then gen_iter approach might be viable. If one despises for loops one can always build custom iterator (~4-5 additional lines) or use hacky range mapping approach ;)

    let mut rng = rand::thread_rng();
    // mean 2, standard deviation 3:
    let normal = Normal::new(2.0, 3.0);
    let v: Vec<_> = (0..10).map(|_| normal.ind_sample(&mut rng)).collect();

@AndyGauge AndyGauge referenced this issue Apr 20, 2018

Closed

Tracking Issues #396

13 of 13 tasks complete
@AndyGauge

This comment has been minimized.

Show comment
Hide comment
@AndyGauge

AndyGauge Apr 23, 2018

Collaborator

Rand is going through an overhaul. 0.5-pre 1 just came out. I would like to revisit this issue once 0.5 ships and evaluate adding recipes later.

Collaborator

AndyGauge commented Apr 23, 2018

Rand is going through an overhaul. 0.5-pre 1 just came out. I would like to revisit this issue once 0.5 ships and evaluate adding recipes later.

@AndyGauge

This comment has been minimized.

Show comment
Hide comment
@AndyGauge

AndyGauge Apr 24, 2018

Collaborator

I read the 0.5 Changelog and the stuff they added was great, but not really helpful to a wide audience. Most of the changes were to support true randomness required for a security perspective. I'm not sure there's a lot of value to a wide audience for this. @pitdicker did a good job in #391 to update the API. I think the cookbook has a good sample of Rand usage.

Collaborator

AndyGauge commented Apr 24, 2018

I read the 0.5 Changelog and the stuff they added was great, but not really helpful to a wide audience. Most of the changes were to support true randomness required for a security perspective. I'm not sure there's a lot of value to a wide audience for this. @pitdicker did a good job in #391 to update the API. I think the cookbook has a good sample of Rand usage.

@AndyGauge AndyGauge closed this Apr 24, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment