Hey @willzanimationz!

So I thought about a solution to your command, since you didn’t give the percent chance of rolling a each number it gave me a lot of space to be creative!

My idea is to use Euler’s number, this way it gets increasingly harder to get selected numbers.

But then, after analyzing the results of my tests with your problematic in mind, turns out it would give me more `12`

than `0`

, which I would have noticed before if I paid more attention to the `ln(x)`

and `e^(x)`

plots. It was the opposite of what we want here. Time to start over? No.

I looked if a simple function that was the vertical mirror of `ln(x)`

existed, but I couldn’t find anything, so I decided to go with what I had, never mind if it doesn’t look as fancy as I wanted it to look like.

So here’s the command to generate a random number between `0`

and `12`

, where it becomes increasingly harder to get the higher numbers:

```
$(eval r=Math.round(Math.log(Math.floor(Math.random()*Math.round(Math.exp(12)))+1)); r==0?`12`:r==1?`11`:r==2?`10`:r==3?`9`:r==4?`8`:r==5?`7`:r==6?`6`:r==7?`5`:r==8?`4`:r==9?`3`:r==10?`2`:r==11?`1`:r==12?`0`:``;)
```

Basically we generate a random number between `0`

and `12`

, and then since we get more `12`

than `0`

, we invert by saying `if the random number is 0, give a 12`

, etc.

With that in mind, here are the percentage of chance to get each number:

```
0 → ~39%
1 → ~38%
2 → ~14%
3 → ~5%
4 → ~2%
5 → ~0.7%
6 → ~0.3%
7 → ~0.1%
8 → ~0.04%
9 → ~0.01%
10 → ~0.005%
11 → ~0.002%
12 → ~0.0006%
```

If you wanted to generate a random number between `1`

and `12`

instead, here’s the command:

```
$(eval r=Math.round(Math.log(Math.floor(Math.random()*Math.round(Math.exp(11)))+1)); r==0?`12`:r==1?`11`:r==2?`10`:r==3?`9`:r==4?`8`:r==5?`7`:r==6?`6`:r==7?`5`:r==8?`4`:r==9?`3`:r==10?`2`:r==11?`1`:``;)
```

In which case the percentage of chance to get each number are:

```
1 → ~63%
2 → ~23%
3 → ~9%
4 → ~3%
5 → ~1%
6 → ~0.4%
7 → ~0.2%
8 → ~0.06%
9 → ~0.02%
10 → ~0.008%
11 → ~0.003%
12 → ~0.001%
```

If you want to have number ranges, so the numbers in the first range have the same percentage of chance, and it get’s harder for higher ranges, here’s what you can do:

- choose your ranges and count them
- flip the results,
`0`

happens the less often, `NUMBER_OF_RANGES-1`

happens the most often
- for ranges with multiple numbers in it, generate randomly one of these with:
`Math.floor(Math.random()*(MAX-MIN+1))+MIN`

**So here’s the command to fit all your needs:**

```
$(eval r=Math.round(Math.log(Math.floor(Math.random()*Math.round(Math.exp(NUMBER_OF_RANGES-1)))+1)); r==0?`HARDEST_RANGE_TO_REACH`:r==1?`SECOND_HARDEST_RANGE_TO_REACH`: ... :r==NUMBER_OF_RANGES-1?`EASIEST_RANGE_TO_REACH`:``;)
```

*If I find a fancier way to do it, meaning if I find the function that is the vertical mirror of *`ln(x)`

, I’ll post an update, as it would be exciting to get the results directly, and not having to flip them.

Example:

I want a command that generate numbers, but it’s harder to get the higher ones, my ranges are: `1-3`

/ `4-6`

/ `7-8`

/ `9-10`

/ `11`

/ `12`

, so it’s really easy to get a number from `1`

to `3`

, slightly less easy to get a number from `4`

to `6`

, etc. and definitely harder to get the number `12`

.

In total I have `6`

ranges, so `NUMBER_OF_RANGES-1 = 5`

So my command will look like this:

```
$(eval r=r=Math.round(Math.log(Math.floor(Math.random()*Math.round(Math.exp(5)))+1)); r==0?`12`:r==1?`11`:r==2?`${Math.floor(Math.random()*2)+9}`:r==3?`${Math.floor(Math.random()*2)+7}`:r==4?`${Math.floor(Math.random()*3)+4}`:r==5?`${Math.floor(Math.random()*3)+1}`:``;)
```

In the end the percentage of chance to get each range of numbers are:

```
1-3 → ~63%
4-6 → ~23%
7-8 → ~9%
9-10 → ~3%
11 → ~1%
12 → ~0.5%
```