"Random number from a range" vs JME random(int1..int2) variables

114 views
Skip to first unread message

David Wishart

unread,
May 18, 2017, 4:50:25 AM5/18/17
to Numbas Users
In short, what's the differences between using these two types of variable?

I know can use the Numbas variable "random number from a range" with a step value to create non-integer random variables and I know that I can use the JME random(int1..int2 except int3) to create a random variables that avoids stated values. I think however that I'm missing something on the JME usage (almost certainly down to how I'm reading the documentation) as looking at the JME Numbas 2.0 documentation there is no mention of the except parameter. I only know this exists from playing about with other people's questions.

Are there any other differences? Are there any fundamental reasons or scenarios when one type is better than the other?

Edited to add
Whilst writing this I've just realised that I think I know the answer to the first part of my question but I'll leave it here as is just in case I've missed something else. I'm guessing that I need to have realised that as one of the argument types for random is a range then looking here shows me what else can be done (I see step is also there as well as except).


Ben Brawn

unread,
May 18, 2017, 8:31:04 PM5/18/17
to Numbas Users
I believe the Numbas variable "random number from a range" with a step value is just to make it easier for people that haven't read the manual (or remembered it all after reading it several times). So no difference. It does the same thing just a nice user interface.

You are also correct in that 'except' and 'step size' are for ranges and not just random, which I guess is why they are not mentioned in the random examples.

David Wishart

unread,
May 19, 2017, 5:20:20 PM5/19/17
to Numbas Users
Thanks, that all makes sense now. Thinking out loud, it might be useful (for me anyway) to have links in each function type to what they can be used with in the documentation. For example in this case, to have the acceptable argument types range and list link to the docs on ranges and lists. I do realise that suggesting this opens me up to receiving a link on how to do GitHub pull requests and GitHub (or least Git) makes me swear and bang my head against the wall enough as it is.

Christian Lawson-Perfect

unread,
May 22, 2017, 3:44:55 AM5/22/17
to Numbas Users
Ben's right - the "random number from a range" data type is just a nice interface around `random(from..to#step)`.
I'll add another example line to the `random` docs using `except` - thanks for pointing out that this isn't documented very well.

I agree that glib "make a pull request!" responses can be quite infuriating when you have no idea how (or, to be fair, no inclination) to do it!

--
You received this message because you are subscribed to the Google Groups "Numbas Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numbas-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Wishart

unread,
May 22, 2017, 4:32:41 AM5/22/17
to Numbas Users
Thanks for your reply. For what its worth, I wasn't suggesting that a "make a pull request" response would be annoying or unjustified, it was more that I was suggesting something that I should easily be able do myself (given me making a bit of effort into learning how to do pull requests etc).
 
Git making me swear lots is more to do with stuff I do outside of Numbas as it seems like I have to learn what I know from scratch every time I go near the system. This probably sums up my experiences.

Reply all
Reply to author
Forward
0 new messages