Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

random() vs gRandom()

Featured Replies

Hello, i would like to ask what is the difference between random() and gRandom() and which one should be used?

They are different methods, read them on the Java Docs. gRandom utilizes standard deviation.

Edited by Final

  • Author

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? 

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

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 by Reveance

  • Author
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?

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 by Reveance

Two different methods the g just initiates that its a "g thang' function.

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 

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 by Imateamcape

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.

 

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 by Imateamcape

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 by Trees

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.

e8afdfc34e4b8d776e3595f1defd808d.png

 

 

 

 

Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.