d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Exponential Random Number
Add Reply New Topic New Poll
Member
Posts: 868
Joined: Jun 10 2010
Gold: 96.51
Jan 28 2013 02:14am
I need a random number generator, lets say 1-10.
1 is very likely to appear and 10 is very unlikely to appear, and everything in between decreases exponentially.
I dont know a good way to do this...
I need an explaination theoretically, and the code, in almost any language, doesent matter.
thanks peace
Member
Posts: 9,803
Joined: Jun 28 2005
Gold: 6.67
Jan 28 2013 03:19am
Why not just take log(rand(1,pow(exp(1),max))) ?
Member
Posts: 868
Joined: Jun 10 2010
Gold: 96.51
Jan 28 2013 04:58am
no idea... explaination?
Member
Posts: 10,812
Joined: Oct 15 2009
Gold: Locked
Warn: 20%
Jan 28 2013 05:40am
create a normal random number between 0 and 10, then use that as the input to a mathematical function that returns what you want....

in other words, draw the distribution you want on a graph, then do a least square fit on it to get the function, then use that function: something like this:



/e
might want to do some rounding at the end if you want an integer

This post was edited by Azrad on Jan 28 2013 05:42am
Member
Posts: 868
Joined: Jun 10 2010
Gold: 96.51
Jan 28 2013 08:41am
Allright, I solved it by myself, but thanks alot anyways ;)
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll