# Modeling traffic according to a distribution.

#### smoking81

##### New Member
Hello everybody!
I'm new in this forum and I hope this is the right place to post this thread..
I'd like to kindly ask you just a suggestion to solve my problem..

I have to model a web server traffic (e.g. user requests per server session) which follows a certain distribution (e.g. an inverse gaussian of which I know mu and lambda). I should code a simulator of such traffic but what I cannot understand is how to use the distribution for generating numbers.
Could you please give me any hint?

Thanks so much since now! Bye

#### TheEcologist

##### Global Moderator
Hello everybody!
I'm new in this forum and I hope this is the right place to post this thread..
I'd like to kindly ask you just a suggestion to solve my problem..

I have to model a web server traffic (e.g. user requests per server session) which follows a certain distribution (e.g. an inverse gaussian of which I know mu and lambda). I should code a simulator of such traffic but what I cannot understand is how to use the distribution for generating numbers.
Could you please give me any hint?

Thanks so much since now! Bye

Which program are you using? And does it have a random number generator that generates numbers with uniform probability?

#### smoking81

##### New Member
Which program are you using? And does it have a random number generator that generates numbers with uniform probability?
unfortunately i have to code on my own in c... let's say i have to get to the bottom of the problem..
thanks again!

#### smoking81

##### New Member
I always thought the C math library had (pseudo) random number functions.

http://www.phanderson.com/C/random.html

Else see this:

http://people.scs.fsu.edu/~burkardt/m_src/uniform/uniform.html

Getting the uniform number generator to work would be the first step to solving your problem. Once you've got that post back.
Hello again! maybe i made some confusion in explaining my problem..
I have to characterize a (web) system load in order to solve an analitical model: in the assignment is given that the requests per session follow an Inverse Gaussian distribution, the user think time a Pareto, the HTML pages' dimension a Lognormal and so on...
My problem is how to use these distributions to get the values which characterize the load....

#### smoking81

##### New Member
Hello again!

I finally understood what I had to do but now i have one final issue: I have to write a C function which generates random numbers according to an Inverse gaussian distribution of which i know mu=3.86 and lambda=9.46...

Values from all other distributions I had to use (eg pareto) have been generated by using CSIM's functions (like pareto(alfa) ), but for inverse Gaussian such a function is not provided so I have to write it...

THANKS A LOT FOR YOUR HELP!
Bye!

#### TheEcologist

##### Global Moderator
Hello again!

I finally understood what I had to do but now i have one final issue: I have to write a C function which generates random numbers according to an Inverse gaussian distribution of which i know mu=3.86 and lambda=9.46...

Values from all other distributions I had to use (eg pareto) have been generated by using CSIM's functions (like pareto(alfa) ), but for inverse Gaussian such a function is not provided so I have to write it...

THANKS A LOT FOR YOUR HELP!
Bye!
This is what I was trying to help you with in the first place.

As stated before the first step is to get a uniform distribution working (so you can randomly generate probabilities from 0 to 1).

Then you use the inverse CDF (or quantile function) of your distribution to generate random numbers.

normal cdf(x)=p
inverse cdf(p)=x

So your uniform[0,1] distribution generates probabilities from 0 to 1. You then use these values with your inverse CDF. This basically "turns” your uniform probabilities into to values from your distribution of choice, it's that simple.

So what you need:

A) uniform dist.
B) the quantile function (inverse cdf) for your inverse Gaussian dist.

Example from the exponential distribution:

CDF =

p=1-exp(-L*x)

Inverse CDF =

1-p = exp(-L * x)
ln(1-p) = -L * x
ln(1-p)/-L = x

note: inverse cdf unsolvable?

I have never tried this for the inverse Gaussian however the standard procedure if your inverse cdf proves unsolvable is to use an optimization algorithm that returns the x value for every p.

Hope this gets you a result,