So i’m trying to figure out what it means when one argument is input into the paranthesis of math.random. I looked it up on the devhub and I don’t understand the definition provided:
“This function is an interface to the simple pseudo-random generator function rand provided by ANSI C. (No guarantees can be given for its statistical properties.) When called without arguments, returns a uniform pseudo-random real number in the range [0,1). When called with an integer number m, math.random returns a uniform pseudo-random integer in the range [1, m]. When called with two integer numbers m and n, math.random returns a uniform pseudo-random integer in the range [m, n].”
It’s simple but it was initially confusing for me as well.
Math.random(1,5)
This just randomly returns a number between 1 & 5 @Deathlios am not sure what that does but I think it randomly generates a number from 0-5
This was explained right in the post above your own. A single value defines an inclusive-maximum between that number and 1. So math.random(5) generates between 1 and 5 including 1 and 5.
“pseudo” means fake, so “pseudo-random” quite literally means “fake random”, and for a good reason. From a computational perspective, true randomness is not feasible. math.random is what is known as a pseudo-random number generator (PRNG). Things can be done to make numbers look random, however the next number is usually based on the previous number.
I didn’t really understand, if you meant giving 1 argument to math.random, this is useful for when you want the minimum number to be 1 but the maximum something greater.
For me, I have very bad practices, I use math.random a lot, I gave 2 values always, maybe I’ve never needed a value between those quantities, its just I need to code more in order to find it useful (for me as I said)