Skip 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.

MethodProvider#gRandom not functioning correctly

Featured Replies

After @Zulrah contacted me to help him with some data, I ran a function I made earlier to collect data to visualize the gRandom's output (using MethodProvider.gRandom(600, 200)). This is the image that I got using 10000 random calls:

58da5a9054cef_scatter-plot-image(2).png.14b140f8c90a1853288a2e8327f39109.png

The discription of the method says that it generates based on normal distribution, then this is is not what the graph should look like, right? Also the method says that it caps based on a secret maximum deviation. However I suspect something's going wrong there too, because every time I've run this function so far, the last value always has a count way higher than the previous ones. It's pretty much like all values above that cap are returned as the cap value, instead of just dismissing them which should be happening.

For the image above end results were: 

1197, 0
1198, 2
1199, 1
1200, 33

Image made using 15 million results by @Stimpack:

FWJVMDB.png

Edited by Reveance

Let me know if you like this better:

 

Random random = new Random();
int stdDeviation = 5;
int mean = 100;
for (int i = 0; i < 50; ++i) {
    double result = random.nextGaussian() * stdDeviation + mean;
    double max = mean + stdDeviation * 3; //68–95–99.7 rule
    if (result > max)
        result = max;
    System.out.println((int) Math.round(result));
}
  • Author
48 minutes ago, Alek said:

Let me know if you like this better:

 


Random random = new Random();
int stdDeviation = 5;
int mean = 100;
for (int i = 0; i < 50; ++i) {
    double result = random.nextGaussian() * stdDeviation + mean;
    double max = mean + stdDeviation * 3; //68–95–99.7 rule
    if (result > max)
        result = max;
    System.out.println((int) Math.round(result));
}

That's actually great! Totally forgot to use that rule, however the only thing is that because you put result = max, if the value is above that range, essentially the 'tail numbers' of the ranges will get a high percentage again. Or in other words the chance of getting result == max is pretty high. Resulting in: 
58dc28180d980_meta-chart(1).thumb.jpeg.8d33c538945805baa6683e48ca884d5b.jpeg


I think the only way to prevent this is by re-generating the random so every value has a fair chance again:

Random random = new Random();
int stdDeviation = 5;
int mean = 100;
for (int i = 0; i < 50; ++i) {
	double maxOffset = stdDeviation * 3; //68–95–99.7 rule
	double result;
	do {
		result = random.nextGaussian() * stdDeviation + mean;
	} while (result > mean + maxOffset || result < mean - maxOffset); // Math.abs(result - mean) > maxOffset, don't know which'd be faster
}

meta-chart.thumb.jpeg.293ac5bb51ef063febd1700bd12af9a5.jpeg

Fair enough, final product looks something like this:

 

Random random = new Random();
int stdDeviation = 5;
int mean = 100;
double max = stdDeviation * 3; //68–95–99.7 rule
for (int i = 0; i < 50; ++i) {
    int result;
    do {
        result = Math.toIntExact(Math.round(random.nextGaussian() * stdDeviation + mean));
    } while (Math.abs(result - mean) > max);
}
  • Alek locked this topic
Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

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.