# Thread: given a random number, output a number with predefined distribution

1. ## given a random number, output a number with predefined distribution

Hello,

I am working on a special effect for a video game. I want to mimic electricity moving through air from one point to another. To make the effect look realistic there needs to be some very random movements but along tightly controlled ranges.

One of the ways I came up of doing this was to imagine a straight line between the two points then place jagged points on the left and right side of the line. These points will be connected by lines to make the jagged look of electricity. Now I want to position those points randomly within a range but with tendencies towards the middle of that range.

Lets say that I place the points within 1 and 100 pixels away from the line. I could easily get a random point between 1 and 100, but instead i want have more numbers closer to the middle (50) then to the edges..... like a bell curve.

Is there a formula I can use that when I input some random numbers (within a range) that I will get back a random number between 1 and 100 but with higher tendencies towards the middle?

thanks
jmart

2. ## Re: given a random number, output a number with predefined distribution

Hey jmartrican.

You can use a result to simulate a normal distribution given that you can simulate a uniform [0,1]:

Inverse transform sampling - Wikipedia, the free encyclopedia

3. ## Re: given a random number, output a number with predefined distribution

Chiro,

Thank you for the response. I'm gonna take a look at that. I was able to find an adequate solution using triangular distribution.

thanks
jmart