Closed Thread Icon

Preserved Topic: quick math help please. Pages that link to <a href="https://ozoneasylum.com/backlink?for=16716" title="Pages that link to Preserved Topic: quick math help please." rel="nofollow" >Preserved Topic: quick math help please.\

 
Author Thread
GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 07-05-2002 00:01

well, im actually stuck at this. trying for an hour with no success...

say i have a variable from 0 to 100 that describes the probability. (or 0 to 1 if you like that)
depending on that i want a return value of true or false referring to the probability.


if this isnt understandable, maybe this example helps:

var x=68;

if (code here) {

execute something;

}


so, the if-statement should be executed with a probability of 0.68. understandable?

i am now searching for the code here part.

big thanks in advance.

edit: FYI: im doing this in actionscript.



[This message has been edited by GRUMBLE (edited 07-05-2002).]

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 07-05-2002 01:25

Should be

if (Math.random() < x/100)

Arthemis
Paranoid (IV) Inmate

From: Milky Way
Insane since: Nov 2001

posted posted 07-05-2002 05:20

or
if (Math.round(100*(Math.random())) <= x)
following slime's



i don't really know what you want, hope that helped... i'm no *real* coder.... i did learn mathematica 4, but right now i'm studying atomic structures and can't really think about anything that doesnt involve 3.14159 in it, so spare me

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 07-05-2002 09:52

cool guys!

thanks a lot!

« BackwardsOnwards »

Show Forum Drop Down Menu