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 mkraska  
#1 Posted : 29 January 2020 02:04:24(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,980
Germany

Was thanked: 1120 time(s) in 718 post(s)
I just came across a nasty difference between random(x) and Random.N(0,x) (the first being native SMath, the second from the Statistical Tools plugin).
If you store random(x) in a variable, the function is called each time the variable is used. If you do that with Random.N(), then a fixed value is stored at definition time, as if there was an internal eval() used.

If you want a fixed value when using random(), then you have to use eval().

The behavour of random() puzzled me when preparing an online worksheet , where I had to fall back to random().

Yet, when remembering that assignment is just storage of an expression with taking into account existing definitions but not doing any computation, then random() behaves consistent and Random.N() does not.

The worksheet would look better without eval() and I can't expect third party readers to understand why it is there.

ran.png
ran.sm (7kb) downloaded 12 time(s).

Edited by user 29 January 2020 02:07:10(UTC)  | Reason: Not specified

Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 1 user thanked mkraska for this useful post.
on 29/01/2020(UTC)

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

Offline Jean Giraud  
#2 Posted : 29 January 2020 14:58:01(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: mkraska Go to Quoted Post
The behavour of random() puzzled me when preparing an online worksheet , where I had to fall back to random().

Try this Martin, it may work in your SS 7251.
Cheers ... Jean

ran Otherwise.sm (24kb) downloaded 14 time(s).

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.