Skip to main content

The term you are looking for is Weighted Random Numbers, most of the algorithms I have seen use trig functions, but I think I figured out a way that will be efficient.:

Create a table/array/List(whatever) that holds a multiplier value for the random function. Fill it out by hand or programatically...

randMulti= {.1,.1,.1,.1,.1,.1,.2,.2,.3,.3,.9,1,1,1,} 

then...then Multiply random by a randomly chosen randMultiand finally by the max Value of the distrobutiondistribution...

weightedRandom = math.random()*randMulti[Math.random(randMulti.length)]*maxValue

I do believe that this will be much faster than using sqrtsqrt, or other more computationalcomputationally complex functions, and will allow for more custom grouping patterns.

The term you are looking for is Weighted Random Numbers, most of the algorithms I have seen use trig functions, but I think I figured out a way that will be efficient.

Create a table/array/List(whatever) that holds a multiplier value for the random function. Fill it out by hand or programatically

randMulti= {.1,.1,.1,.1,.1,.1,.2,.2,.3,.3,.9,1,1,1,} 

then Multiply random by a randomly chosen randMultiand finally by the max Value of the distrobution

weightedRandom = math.random()*randMulti[Math.random(randMulti.length)]*maxValue

I do believe that this will be much faster than using sqrt, or other more computational complex functions, and will allow for more custom grouping patterns.

The term you are looking for is Weighted Random Numbers, most of the algorithms I have seen use trig functions, but I think I figured out a way that will be efficient:

Create a table/array/List(whatever) that holds a multiplier value for the random function. Fill it out by hand or programatically...

randMulti= {.1,.1,.1,.1,.1,.1,.2,.2,.3,.3,.9,1,1,1,} 

...then Multiply random by a randomly chosen randMultiand finally by the max Value of the distribution...

weightedRandom = math.random()*randMulti[Math.random(randMulti.length)]*maxValue

I do believe that this will be much faster than using sqrt, or other more computationally complex functions, and will allow for more custom grouping patterns.

Source Link
AttackingHobo
  • 7.1k
  • 4
  • 37
  • 48

The term you are looking for is Weighted Random Numbers, most of the algorithms I have seen use trig functions, but I think I figured out a way that will be efficient.

Create a table/array/List(whatever) that holds a multiplier value for the random function. Fill it out by hand or programatically

randMulti= {.1,.1,.1,.1,.1,.1,.2,.2,.3,.3,.9,1,1,1,} 

then Multiply random by a randomly chosen randMultiand finally by the max Value of the distrobution

weightedRandom = math.random()*randMulti[Math.random(randMulti.length)]*maxValue

I do believe that this will be much faster than using sqrt, or other more computational complex functions, and will allow for more custom grouping patterns.