T
T
toolen2014-12-25 19:20:39
Probability theory
toolen, 2014-12-25 19:20:39

How to generate random numbers in a range according to different distribution laws?

Hello colleagues!
I am writing a network traffic generator, where the size of generated packets obeys one of the distribution laws, the problem is that the size should range from 42 to 508, and distribution sampling can give completely different ranges. Are there any methods to get a specific distribution in a specific range of values? I will be very grateful for the answers!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2014-12-25
@Rsa97

One of the purely specific methods for a discrete random variable (I will show on the example of 5 values):
Let it be necessary to obtain five values ​​[A..E] with probability ratios 2:7:5:3:4.
1. Construct the cumulative sum of probabilities: 2:9:14:17:21
2. Divide the obtained values ​​by the final sum (21): 0.095:0.429:0.667:0.809:1
3. Generate a pseudo-random value X in the range [0:1) with an even distribution.
4. Let's go through the resulting array. As soon as X becomes less than the next element of the array, we have the desired element.

S
Spetros, 2014-12-25
@Spetros

the problem is that the size should range from 42 to 508

It's not a problem, it's more of an inability to think.
If there is a function that generates random values ​​according to one of the distribution laws, then it is easy to associate it with a range of values.
Obviously, these ranges need to be reduced to the required one.
Yes, with the help of mathematics, one range is reduced to another.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question