<div class="quoteheader"><div class="topslice_quote"><a href="https://elliquiy.com/forums/index.php?topic=72345.msg3275878#msg3275878">Quote from: NosCorventius on 11-07-2010, 16:27:53</a></div></div><blockquote class="bbc_standard_quote">ok while I understand what a gamma distrabution is the formula for figuring out such numbers just made my head explode. I am a proud geek but my nerd status is somewhat in question as my higher mathimatical functions do not exist. If you could break down what went where maybe this would be hepful but as a symbol filled formula it makes as much sense to me as wingdings does to everyone else. Sorry.<br/></blockquote><div class="quotefooter"><div class="botslice_quote"></div></div><br/>So, I'm going to make this more approachable by essentially skipping the math entirely and going directly to a way (admittedly inefficient), to generate random numbers from an arbitrary distribution. Since its a game, you don't actually have to generate that many, so the fact that this is an utterly pants way to do this for, say, a few million random numbers doesn't matter. You need the following things:<br/><br/>1. A piece of graph paper. Graph paper is handy. Preferably the engineering stuff with the tiny squares.<br/>2. A d100, or two d10 dice. Another die of some sort.<br/>3. Time.<br/><br/>And we begin...<br/><br/>1. Draw yourself a square. A big one. Mark out as many values on both the X and Y axis that you can. The highest values on the Y axis is 1, the highest value on the X-axis is whatever you want to be rolling from. For this, lets say you have a d6. That means your buff duration can go between 0 and 5 hours (we're doing to treat a roll of 1 as 0, 2 as 1, etc.).<br/><br/>2. In said square, draw the distribution you want your buff durations to follow. This can literally be<em>any</em>valid distribution. My suggestion is you come up with a step function, as they're pretty easy. For example:<br/><br/>"Most of the time, the buff lasts three hours. Occasionally, it fizzles out almost immediately, and its extremely rare that it will last more than four hours."<br/><br/>So we get a step function like this:<br/><br/>0-1 hours: 0.20<br/>1-2 hours: 0.05<br/>2-3 hours: 0.20<br/>3-4 hours: 0.50<br/>4-5 hours: 0.05<br/><br/>Notice how they sum to 1.<br/><br/>That's not hard to draw out on your square. Draw the function, shade the part underneath the line you've drawn.<br/><br/>3. Roll them dice! Roll a d6 for the X axis, and (d100 or 2d10)/100 for the Y-axis, using the first dice as the tens digit and the 2nd as the ones digit.<br/><br/>You now have a pair of numbers. For your X roll, take the (Roll - 1) + tinytiny number. This is your "candidate roll". Essentially, its a possible buff duration. So if you rolled a 3, its in the 2-3 hour range.<br/><br/>Now your Y-axis roll is some number between 0 and 1. Plot the point on your graph. Is it in the shaded area? Then you accept your candidate roll, and this is your randomly generated buff duration. Is it not in the shaded area? Toss it and roll again.<br/><br/>And there you go. Randomly generated numbers from an arbitrary distribution. The rather clearly named "Accept-Reject" algorithm. A die with more numbers on the X-axis (d10, d20 etc.) allows for a greater degree of granularity in the step function you come up with.<br/><br/>