Using the random function

Using the random function - Messages

#1 Posted: 6/26/2010 3:26:24 AM
Brian Runagle

Brian Runagle

13 likes in 27 posts.

Group: User

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
#2 Posted: 6/26/2010 2:35:56 PM
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

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
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#3 Posted: 6/27/2010 2:09:48 AM
Brian Runagle

Brian Runagle

13 likes in 27 posts.

Group: User

Thanks Radovan, that's just what I wanted.

Brian
#4 Posted: 6/27/2010 2:57:18 AM
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

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
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
  • New Posts New Posts
  • No New Posts No New Posts