Skip to content

Add ctx.rng_{weighted|ratio}_bool() helper functions#124

Merged
abey79 merged 1 commit into
masterfrom
weighted-bool-rng
Feb 4, 2024
Merged

Add ctx.rng_{weighted|ratio}_bool() helper functions#124
abey79 merged 1 commit into
masterfrom
weighted-bool-rng

Conversation

@abey79

@abey79 abey79 commented Feb 4, 2024

Copy link
Copy Markdown
Owner

This PR adds to functions to whiskers::Context:

  • ctx.rng_weighted_bool(prob: f64): random bool with give probability of true
  • ctx.rng_ratio_bool(num: u32, denim: u32): same, but with probability expressed as a num/denom ratio

The latter variant is useful for when dealing with, e.g., column or row index:

let some_bool = ctx.rng_ratio_bool(current_columns, (total_column - 1));

@abey79 abey79 added whiskers Relates to whiskers or whiskers-derive feature New feature labels Feb 4, 2024
@abey79 abey79 merged commit ccffc6c into master Feb 4, 2024
@abey79 abey79 deleted the weighted-bool-rng branch February 4, 2024 15:17
@abey79 abey79 changed the title Add ctx.rng_{weighted|ratio}_bool() help functions Add ctx.rng_{weighted|ratio}_bool() helper functions Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature whiskers Relates to whiskers or whiskers-derive

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant