{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang-nursery/rand/issues/494","repository_url":"https://api.github.com/repos/rust-lang-nursery/rand","labels_url":"https://api.github.com/repos/rust-lang-nursery/rand/issues/494/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang-nursery/rand/issues/494/comments","events_url":"https://api.github.com/repos/rust-lang-nursery/rand/issues/494/events","html_url":"https://github.com/rust-lang-nursery/rand/issues/494","id":329365030,"node_id":"MDU6SXNzdWUzMjkzNjUwMzA=","number":494,"title":"Compromising accuracy and speed [distributions]","user":{"login":"dhardy","id":134893,"node_id":"MDQ6VXNlcjEzNDg5Mw==","avatar_url":"https://avatars1.githubusercontent.com/u/134893?v=4","gravatar_id":"","url":"https://api.github.com/users/dhardy","html_url":"https://github.com/dhardy","followers_url":"https://api.github.com/users/dhardy/followers","following_url":"https://api.github.com/users/dhardy/following{/other_user}","gists_url":"https://api.github.com/users/dhardy/gists{/gist_id}","starred_url":"https://api.github.com/users/dhardy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhardy/subscriptions","organizations_url":"https://api.github.com/users/dhardy/orgs","repos_url":"https://api.github.com/users/dhardy/repos","events_url":"https://api.github.com/users/dhardy/events{/privacy}","received_events_url":"https://api.github.com/users/dhardy/received_events","type":"User","site_admin":false},"labels":[{"id":173092859,"node_id":"MDU6TGFiZWwxNzMwOTI4NTk=","url":"https://api.github.com/repos/rust-lang-nursery/rand/labels/E-question","name":"E-question","color":"00ffaa","default":false},{"id":776652275,"node_id":"MDU6TGFiZWw3NzY2NTIyNzU=","url":"https://api.github.com/repos/rust-lang-nursery/rand/labels/T-distributions","name":"T-distributions","color":"ffbf00","default":false},{"id":866963732,"node_id":"MDU6TGFiZWw4NjY5NjM3MzI=","url":"https://api.github.com/repos/rust-lang-nursery/rand/labels/X-discussion","name":"X-discussion","color":"bfbfbf","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-06-05T09:06:21Z","updated_at":"2018-06-06T07:37:20Z","closed_at":null,"author_association":"COLLABORATOR","body":"This is an issue that has been discussed in part several times already in other contexts. But I think it's now worth making an issue specifically about this to get extra feedback.\r\n\r\n---\r\n\r\nThere are several cases within distribution algorithms that we've had to make decisions about speed-vs-accuracy trade-offs:\r\n\r\n- `Standard` now uses 24/53 bits precision (#416); we have discussion around a high-precision variant (#372)\r\n- `Uniform` (for ranges) uses a rejection zone to avoid bias; as [noted here](https://github.com/rust-lang-nursery/rand/pull/491#issuecomment-394259079) we can sometimes use faster approaches if we don't care about small amounts of bias\r\n- `gen_bool` has at least 3 possible implementations with varying accuracy and speed (#411)\r\n- `gen_ratio` is a nice addition to `gen_bool` with at least two different approachs (#491)\r\n\r\nSo far, other than with the suggested addition of a `HighPrecision` distribution (#372) (and the other float sampling methods `Open01` and `OpenClosed01`), we have not given users any choice over this speed-vs-accuracy trade-off but have simply made the choice for users.\r\n\r\n- Should we try to give users the choice, some how?\r\n- Which criteria should we use to choose default implementations?"},"comment":{"url":"https://api.github.com/repos/rust-lang-nursery/rand/issues/comments/394971175","html_url":"https://github.com/rust-lang-nursery/rand/issues/494#issuecomment-394971175","issue_url":"https://api.github.com/repos/rust-lang-nursery/rand/issues/494","id":394971175,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NDk3MTE3NQ==","user":{"login":"pitdicker","id":6255050,"node_id":"MDQ6VXNlcjYyNTUwNTA=","avatar_url":"https://avatars1.githubusercontent.com/u/6255050?v=4","gravatar_id":"","url":"https://api.github.com/users/pitdicker","html_url":"https://github.com/pitdicker","followers_url":"https://api.github.com/users/pitdicker/followers","following_url":"https://api.github.com/users/pitdicker/following{/other_user}","gists_url":"https://api.github.com/users/pitdicker/gists{/gist_id}","starred_url":"https://api.github.com/users/pitdicker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pitdicker/subscriptions","organizations_url":"https://api.github.com/users/pitdicker/orgs","repos_url":"https://api.github.com/users/pitdicker/repos","events_url":"https://api.github.com/users/pitdicker/events{/privacy}","received_events_url":"https://api.github.com/users/pitdicker/received_events","type":"User","site_admin":false},"created_at":"2018-06-06T07:37:20Z","updated_at":"2018-06-06T07:37:20Z","author_association":"COLLABORATOR","body":"That is a very good summary, @dhardy!\r\n\r\nWe seem to be in a bit of a difficult position, as Rand is used for some very different use cases:\r\n- randomness in common programming problems\r\n- reasonably secure randomness\r\n- long-running simulations\r\n\r\nIn my opinion, we should strongly optimize for the 'common programming problems' (security does not really apply here). Is seems reasonable to expect anyone who writes multiple-month simulations to spend an hour reading docs, or know the limitations of the algorithms he is using.\r\n\r\nI like suggestion 1 most, but would also like to see 3 when reasonable.\r\n\r\nSpecifically:\r\n- `gen_bool`: return to the 32-bit accuracy, and have the `Bernoulli` distribution for 53~64 bit accuracy. One optimized for common use, one for long-running simulations.\r\n- Have both `Standard` and `HighPrecision01`.\r\n- `Uniform` range: have to think a bit more about this one. An imperfect method is a good choice when the numbers are relatively small. Maybe we can make it depend on the type, with the faster, but imperfect, method for `u8` and `u16`?\r\n\r\nLetting the accuracy depend on the RNG as @sicking suggest is also an interesting idea. But the distinction should not be between normal PRNGs and CSPRNGs. Accuracy is not really a security-related problem. PRNGs that are suitable for simulations are also the ones that are suitable for many common problems. I would say the suitability depends more on where the function is used, than the RNG."}}
{"actor":{"display_login":"pitdicker"}}