I've tried fruitlessly to produce a function that returns true or false based on a probability value (0 - 1)
This is something i thought initially
1 2 3
|
bool b=true;
for(int i=0; i<N; ++i)
b &= [random analog state]
|
But this only produces 1/2
N probabilities
help?
Last edited on
So you want a 50% chance of b being 1? Or...
-Albatross
Oh sorry, I didnt state this clearly... I want a function that returns true of false based on a variable probability (of returning true)
|
bool randomBool(double p) { /* Code */ }
|
Last edited on
I'm being foolish... I just realized i could just do:
{ return rand() % N == 0 }
sorry. I solve problems this way sometimes :)
thanks anyway
Aw... the person who asked the question beat me to the answer.
All well, it's better that way, actually.
-Albatross