# Making a random number generator with custom probability distribution

I wish to obtain a random number, however i wish for a certain range of numbers to be more likley than others. For example, 0 would be very unlikley and probability of each number increaces till 4, then falls after that.

I don’t know how to achieve this.

It would be nice if I could define a function which represents probability for the given range, like a sine wave, where the higher the wave at a number, the greater the probability of that number being chosen.

The best I can think of is making a loop which fills a list with numbers, repeating more probable numbers more in the list, but this feels inefficient, especially for large numbers.

I wont need nonintegers… probably

Ideas?

1 Like

Simpily make a group of numbers equal certain values e.g if you were doing item drops and you want common items to appear alot you can make the number 1 actuall be 1-10 and then 2 would continue from 10 onwards. Then the total number of slots taken per number as to the total of all the numbers would be your actual probability of drawing that item ir rarity. (Each number would be an item)

1 Like

Ooh thank you, I’ll wait and see if other people have other ideas but I’ll probably use this

make a list, each number with a weight eg:

1 = 6
2 = 2
3 = 4

ect,

then do a random calculation, since 1 has 6 numbers with it, its most likely so on and so forth