PJYelton

04-02-2003, 10:10 AM

Ok, I wasn't sure where to post this so I'll try GD. If the mods feel it belongs in the c++ forum, then thats ok.

I am trying to write a function but am having problems with the math concept of it. What I want is to have a function return a random number based on the following four parameters: the minimum value it can be, the maximum value it can be, and a median and slope number that I'll explain in a second. Basically what I have in mind is something that resembles a bell curve function. The median number is the highest point in the curve and will be the most likely number returned by the function. Depending on how steep the slope parameter is, the lower the probability of getting a number farther away from the median. So for convenience sake, lets say that the possible values of the slope are 0%-100%. Then 99% means that it is extremely unlikely to get a number far away from the median, and you are almost guaranteed of getting the median or a number right next to the median. As the slope gets smaller, the probability of finding a number farther away increases, until you get a slope of 0% which means all numbers between the max and min are equally possible.

An example would be something like:

min:2 max:8 median:5 slope:75%

has this probability which is arbitrary at the moment (doesn't have to be these exact percentages):

return 2:3% 3:7% 4:15% 5:50% 6:15% 7:7% 8:3%

Lately I've come across quite a few uses for something like this. I'm just looking for some time of general equation or help on how to write something small like this. Don't need code, just a quick kick in the right direction will do :)

I am trying to write a function but am having problems with the math concept of it. What I want is to have a function return a random number based on the following four parameters: the minimum value it can be, the maximum value it can be, and a median and slope number that I'll explain in a second. Basically what I have in mind is something that resembles a bell curve function. The median number is the highest point in the curve and will be the most likely number returned by the function. Depending on how steep the slope parameter is, the lower the probability of getting a number farther away from the median. So for convenience sake, lets say that the possible values of the slope are 0%-100%. Then 99% means that it is extremely unlikely to get a number far away from the median, and you are almost guaranteed of getting the median or a number right next to the median. As the slope gets smaller, the probability of finding a number farther away increases, until you get a slope of 0% which means all numbers between the max and min are equally possible.

An example would be something like:

min:2 max:8 median:5 slope:75%

has this probability which is arbitrary at the moment (doesn't have to be these exact percentages):

return 2:3% 3:7% 4:15% 5:50% 6:15% 7:7% 8:3%

Lately I've come across quite a few uses for something like this. I'm just looking for some time of general equation or help on how to write something small like this. Don't need code, just a quick kick in the right direction will do :)