Skip to content
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

introduce and use weighted_maybe/2 #2689

Merged
merged 1 commit into from
Dec 14, 2024
Merged

Conversation

triska
Copy link
Contributor

@triska triska commented Dec 8, 2024

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 #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.
@mthom mthom merged commit a9a7777 into mthom:master Dec 14, 2024
13 checks passed
@hurufu
Copy link
Contributor

hurufu commented Dec 14, 2024

Informal proof of correct probabilities:

% Given that numbers from interval [0,N) are equally likely, X has N possible
% values with 1/N probability. Observe that for every non-negative value K ≤ N:
% if K = 0 then P(X < 0) = 0   (No value X exist)
% if K = 1 then P(X < 1) = 1/N (when X = 0)
% if K = 2 then P(X < 2) = 2/N (when X = 0 or X = 1)
% ...
% if K = N then P(X < N) = 1   (for all possible values of X)
%
% Which exactly corresponds to our expectation, that goals succeeds with
% probability K/N.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants