-
Notifications
You must be signed in to change notification settings - Fork 126
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
maybe/2 would be a useful addition to library(random) #2670
Comments
Note that there are systems (the original CLP(R) comes to mind) that do not produce as a full leaf answer containing constraints but instead just say |
Yes indeed, very good point, a better name is also worth considering! |
Can this be enough? maybe(K, N) :-
maplist(integer_si, [K, N]),
random_integer(0, N, X),
X < K. |
Something in this direction would be perfect, if the bounds are correctly chosen to yield the correct probabilities! |
Also just a comment. For any serious security based application Prolog language should support multiple RNG instances for different purposes. For example if a program uses the same RNG to both generate access tokens and for UI animation, then it is much easier to predict next access tokens just by observing UI animation. |
Yes, ideally we need a way to explicitly generate and pass an "rng context" to rng functions so that we have control of this. It would also make things more declarative, depending on how the rng context works. |
This is until library(random) provides this functionality, and a good name is found for it. See mthom#2670.
Many thanks to @hurufu for the very nice definition! This is until library(random) provides this functionality, and a good name is found for it. See mthom#2670.
A generalization of
maybe/0
would be a useful addition tolibrary(random)
:maybe(+K, +N)
, succeeding with probabilityK/N
.This is needed for
library(clpb)
, where we currently have:@notoria and everyone who is interested in arithmetic and probabilistic functionality, I would greatly appreciate your help with this!
The text was updated successfully, but these errors were encountered: