mskod Posted April 15, 2017 Share Posted April 15, 2017 Hello, i would like to ask what is the difference between random() and gRandom() and which one should be used? Link to comment Share on other sites More sharing options...
Final Posted April 15, 2017 Share Posted April 15, 2017 (edited) They are different methods, read them on the Java Docs. gRandom utilizes standard deviation. Edited April 15, 2017 by Final 1 Link to comment Share on other sites More sharing options...
Tylersbored Posted April 15, 2017 Share Posted April 15, 2017 Use gRandom if you want there to be weights on the values that get picked 1 Link to comment Share on other sites More sharing options...
mskod Posted April 15, 2017 Author Share Posted April 15, 2017 So if i use unique number and generate random number based on it, i will get different random number distribution (which changes observable pattern) for each unique number? Link to comment Share on other sites More sharing options...
Final Posted April 15, 2017 Share Posted April 15, 2017 19 minutes ago, mskod said: So if i use unique number and generate random number based on it, i will get different random number distribution (which changes observable pattern) for each unique number? Uhmmmm not quite http://lmgtfy.com/?q=standard+deviation Link to comment Share on other sites More sharing options...
Reveance Posted April 15, 2017 Share Posted April 15, 2017 (edited) gRandom is broken, if you want to use a random with normal distribution you can use But yeah, gRandom uses normal distribution which is one random distribution that very simplified basically gives more chance to numbers around the center (mean) and the deviation says how wide the field of more chance is :p. Normal random uses uniform distribution which means there's an even chance for every number Edited April 15, 2017 by Reveance 2 Link to comment Share on other sites More sharing options...
mskod Posted April 15, 2017 Author Share Posted April 15, 2017 1 hour ago, Reveance said: gRandom is broken, if you want to use a random with normal distribution you can use But yeah, gRandom uses normal distribution which is one random distribution that very simplified basically gives more chance to numbers around the center (mean) and the deviation says how wide the field of more chance is :p. Normal random uses uniform distribution which means there's an even chance for every number So if i use: gRandom(50,10,0,100) 50 - mean 10 - stdDeviation 0 - min number 100 - max number Will i get random numbers from 0 - 100, but mainly they will be from 40-60? Link to comment Share on other sites More sharing options...
Reveance Posted April 15, 2017 Share Posted April 15, 2017 (edited) 17 minutes ago, mskod said: So if i use: gRandom(50,10,0,100) 50 - mean 10 - stdDeviation 0 - min number 100 - max number Will i get random numbers from 0 - 100, but mainly they will be from 40-60? You switched one param as mean is the second one, but correct :P... so gRandom(10, 50, 0, 100). This will result in the heigest chance to roll between 40 and 60. 99.7% of the values will lie between 20 and 80. It might be easier to use gRandomBetween though, this automatically calculates the mean and deviation so that the above example would be equivalent to gRandomBetween(20, 80) with the difference of having a cap between 20, 80 instead of 0, 100 Edited April 15, 2017 by Reveance 1 Link to comment Share on other sites More sharing options...
Xardason Posted April 15, 2017 Share Posted April 15, 2017 Two different methods the g just initiates that its a "g thang' function. Link to comment Share on other sites More sharing options...
Juggles Posted April 15, 2017 Share Posted April 15, 2017 Random- all values have an equal chance of occuring between two intervals. Grandom(when working correctly) - copies a more human pattern, numbers are centralized around the mean. 99.7% of values will lie within 3 deviations Link to comment Share on other sites More sharing options...
Team Cape Posted April 16, 2017 Share Posted April 16, 2017 (edited) Just going to clear up a few things. A normal distribution is *not* a uniform distribution, and has a standard deviation, but is by no means composed of just a standard deviation (@Final). A normal distribution has a mean and standard deviation. 68% of the values in a normal distribution are within the first standard deviation (+/-); 95% are within the second (think it's 95.3% but I can't be sure); 99.7% are within the third. gRandom(), which is now fixed not fixed, utilizes a normal distribution, and is in no way a replacement for random(). random() uses a uniform distribution, in which each number has an equal probability of occurring, meaning gRandom() is *not* the same thing is based upon the details above. If you don't know how it's used, I wouldn't recommend using it. Edit: It looks like gRandom() only uses the right side of the normal distribution. Edited April 16, 2017 by Imateamcape 1 Link to comment Share on other sites More sharing options...
Trees Posted April 16, 2017 Share Posted April 16, 2017 gRandom likely stands for gaussian random. Random - Most randomness, always random number within values. gRandom - Still random, but more likely to be closer to the median value of the range. Ex. random(0, 100) - 30, 20, 5, 86, 40, 33, 99, 44, 33, 11, etc./ gRandom(0, 100) - 30, 44, 66, 55, 23, 10, 0, 75 (values closer to 50) It's useful, because although statistically you have less variation, you can still get the full range. Which means you will normally have average values, but can still have outliers. Link to comment Share on other sites More sharing options...
Team Cape Posted April 16, 2017 Share Posted April 16, 2017 (edited) 22 minutes ago, Trees said: gRandom likely stands for gaussian random. Random - Most randomness, always random number within values. gRandom - Still random, but more likely to be closer to the median value of the range. Ex. random(0, 100) - 30, 20, 5, 86, 40, 33, 99, 44, 33, 11, etc./ gRandom(0, 100) - 30, 44, 66, 55, 23, 10, 0, 75 (values closer to 50) It's useful, because although statistically you have less variation, you can still get the full range. Which means you will normally have average values, but can still have outliers. No. Edited April 16, 2017 by Imateamcape Link to comment Share on other sites More sharing options...
Trees Posted April 16, 2017 Share Posted April 16, 2017 (edited) 1 hour ago, Imateamcape said: No. Yeah, it's just a standard random with gaussian values, probably using some like a box-muller transform. Edited April 16, 2017 by Trees Link to comment Share on other sites More sharing options...
Final Posted April 16, 2017 Share Posted April 16, 2017 7 hours ago, Imateamcape said: Just going to clear up a few things. A normal distribution is *not* a uniform distribution, and has a standard deviation, but is by no means composed of just a standard deviation (@Final). A normal distribution has a mean and standard deviation. 68% of the values in a normal distribution are within the first standard deviation (+/-); 95% are within the second (think it's 95.3% but I can't be sure); 99.7% are within the third. gRandom(), which is now fixed not fixed, utilizes a normal distribution, and is in no way a replacement for random(). random() uses a uniform distribution, in which each number has an equal probability of occurring, meaning gRandom() is *not* the same thing is based upon the details above. If you don't know how it's used, I wouldn't recommend using it. Edit: It looks like gRandom() only uses the right side of the normal distribution. I mean we are here to educate him about the use of it, that was a lot of facts which could be found from my original series of posts. Learn what standard deviation is. Read the API Docs on the method: "Generates a random integer based on a normal distribution between 0 and a capped value based on a secret maximum deviation based on the standard deviation." . You now know that the method uses normal distribution, has secret capped value and the value is always 0 or more. This means the positive (right) bound is only used so that negatives are impossible to appear. Use this calculator to see how your numbers are effecting this method: http://davidmlane.com/hyperstat/z_table.html TL;DR: gRandom uses normal distribution to calculate a number, this means we need a mean and an SD for a degree of deviation. The method then only selects from the right bound, we means the selected value can only be larger than the original value. The reason for gRandom being broken is that the method only uses the right side of the possible values, meaning we can't get anything less than the original value. This is good as it is impossible to retrieve negative numbers from the method, however it means that in certain cases such as the example below, we can't access the left bound values, which is an issue in a lot of cases. I believe this was purposely implemented as gRandom in a lot of cases would actually return a negative value, when this value is attempting to impact things such as sleep, you can see why you wouldn't want a negative value in this case. Link to comment Share on other sites More sharing options...