1 Pages (4 items)
Using the random function - Messages
#1 Posted: 6/26/2010 3:26:24 AM
Hi
I have a problem using the random function.
If I assign a random number to a variable, x=random(6) for example, and look at the value once I see a value, say x=4. If I look at it again I get a different number, say x=2, and so on. It's as if looking at the variable x calls the random function again.
This also occurs in SMath Live.
The question is then, how can I "freeze" the value of x so that I can work with a random value without it changing every time I look at it?
Many thanks
Brian
I have a problem using the random function.
If I assign a random number to a variable, x=random(6) for example, and look at the value once I see a value, say x=4. If I look at it again I get a different number, say x=2, and so on. It's as if looking at the variable x calls the random function again.
This also occurs in SMath Live.
The question is then, how can I "freeze" the value of x so that I can work with a random value without it changing every time I look at it?
Many thanks
Brian
#2 Posted: 6/26/2010 2:35:56 PM
Hello Brian,
Just select the region x=random(6) and right clik on it. Choose Optimization=>Numeric. After that you can work with the random number, and x random value is "freezed" then. If you want to use another random number just Recalculate page (F9)
Regards,
Radovan
Just select the region x=random(6) and right clik on it. Choose Optimization=>Numeric. After that you can work with the random number, and x random value is "freezed" then. If you want to use another random number just Recalculate page (F9)
Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#3 Posted: 6/27/2010 2:09:48 AM
Thanks Radovan, that's just what I wanted.
Brian
Brian
#4 Posted: 6/27/2010 2:57:18 AM
You are welcome
I suggest you to use SMath Wiki and, of course, to use this Forum in order to express your opinion how to improve SMath or to report bugs as well.
Regards,
Radovan

I suggest you to use SMath Wiki and, of course, to use this Forum in order to express your opinion how to improve SMath or to report bugs as well.
Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
1 Pages (4 items)
-
New Posts
-
No New Posts