Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline bdrunagle  
#1 Posted : 26 June 2010 10:26:24(UTC)
bdrunagle


Rank: Member

Groups: Registered
Joined: 18/05/2010(UTC)
Posts: 27
Man
United Kingdom

Was thanked: 13 time(s) in 6 post(s)
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

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline omorr  
#2 Posted : 26 June 2010 21:35:56(UTC)
omorr


Rank: Administration

Groups: Registered, Advanced Member
Joined: 23/06/2009(UTC)
Posts: 1,740
Man
Serbia

Was thanked: 318 time(s) in 268 post(s)
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

Edited by user 26 June 2010 21:37:28(UTC)  | Reason: Not specified

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline bdrunagle  
#3 Posted : 27 June 2010 09:09:48(UTC)
bdrunagle


Rank: Member

Groups: Registered
Joined: 18/05/2010(UTC)
Posts: 27
Man
United Kingdom

Was thanked: 13 time(s) in 6 post(s)
Thanks Radovan, that's just what I wanted.

Brian
Offline omorr  
#4 Posted : 27 June 2010 09:57:18(UTC)
omorr


Rank: Administration

Groups: Registered, Advanced Member
Joined: 23/06/2009(UTC)
Posts: 1,740
Man
Serbia

Was thanked: 318 time(s) in 268 post(s)
You are welcome Good

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!"
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.