# Math Formula for "gradiated" randoms?

### » Wed Dec 15, 2010 5:56 am

[quote="newt":312t07ll]So say your mean is 10, and the sigma is 10 you will get any random number between 10-10, and 10+10....[/quote:312t07ll]
Kind of, but sigma is just the width of the bell curve. Specifying 10 doesn't actually mean it will give you a number that's either ten greater or ten less. Here, I made this .cap. A sigma of 4 gives you around about a 32 number deviation from the mean with normally distributed probabilities. Any number is actually possible, but the chance is really small. You should clamp the value if you want it to stay within a certain range.

B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

### » Fri Dec 17, 2010 10:25 am

The math geek in me forced me to register just to answer this question.

There's a really simple way to get almost exactly what you're after: For every random value you need, generate two random values and pick the lowest. For values of 1-100, that should give you:

1-30: 51% of the time
31-60: 33% of the time
61-100: 16% of the time

1-10: 19% of the time
91-100: 1% of the time

Should be about the same for 0-100.
B
1
G
2
Posts: 2
Reputation: 629

### » Fri May 20, 2011 2:05 pm

^
Just tested this out and it works pretty good, with the exception that the number 100 will never be returned because your always choosing the lower value.
B
160
S
48
G
79
Posts: 7,230
Reputation: 60,988

### » Fri May 20, 2011 2:27 pm

but what if they're both 100?
B
126
S
63
G
16
Posts: 1,763
Reputation: 18,772

### » Fri May 20, 2011 2:46 pm

Well the formula I used was:
set pv1 to ran(100)+1, set pv2 to ran(100)+1
if pv1 is less than pv2 set pv3 to pv1
if pv2 is less than pv1 set pv3 to pv2

So basically duplicates are bypassed.
B
160
S
48
G
79
Posts: 7,230
Reputation: 60,988

Previous

### Who is online

Users browsing this forum: No registered users and 2 guests