Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
True or false output based on a probability
package main
import (
func Decision(probability float64) bool {
// randFloat64() returns a float64, `0.0 <= f < 1.0`
return rand.Float64() <= probability
func main() {
counts := make(map[bool]int)
for i:=0; i < 100000; i++ {
res := Decision(0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.