Using the random function

Using the random function - Mensajes

#1 Publicado: 26/6/2010 3:26:24
Brian Runagle

Brian Runagle

13 me gusta en 27 mensajes.

Grupo: 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 Publicado: 26/6/2010 14:35:56
Radovan Omorjan

Radovan Omorjan

325 me gusta y 1 no me gusta en 2.052 mensajes.

Grupo: 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 Publicado: 27/6/2010 2:09:48
Brian Runagle

Brian Runagle

13 me gusta en 27 mensajes.

Grupo: User

Thanks Radovan, that's just what I wanted.

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

Radovan Omorjan

325 me gusta y 1 no me gusta en 2.052 mensajes.

Grupo: 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!"
  • Nuevos mensajes
  • Sin mensajes nuevos