## exponential distribution function given lambda in C

### exponential distribution function given lambda in C

Hai,

I use the C programming language and unders solaris platform.

I was trying to find out the function in 'C' that would return me the
exponential distribution value, given lambda as the argument. Can you

Thanks a lot for your time.

Ramakrishnan V

### exponential distribution function given lambda in C

>I was trying to find out the function in 'C' that would return me the
>exponential distribution value, given lambda as the argument. Can you

Let uniform() be your favorite random number generator that returns
a random float/double in the range  0.0 < uniform() < 1.0.

Then I think -lambda*log(uniform()) will be exponentially distributed.
At least that is what some old code of my does.

--
http://www.math.fsu.edu/~bellenot
bellenot <At/> math.fsu.edu
+1.850.644.7189 (4053fax)

### exponential distribution function given lambda in C

Hai,

Thanks a lot for the response.

I have anohter doubt regarding the same.

Does that work if i were also asked to generate it given mean. What i
am trying to do is to generate jobs in an exponentially distributed
fashion given the mean.

like "The inter-arrival time of jobs is exponentially distributed with
mean of ...".

Thanks a lot for your time.

Sincerely,
Ramakrishnan V

> >I was trying to find out the function in 'C' that would return me the
> >exponential distribution value, given lambda as the argument. Can you

> Let uniform() be your favorite random number generator that returns
> a random float/double in the range  0.0 < uniform() < 1.0.

> Then I think -lambda*log(uniform()) will be exponentially distributed.
> At least that is what some old code of my does.

### exponential distribution function given lambda in C

>Does that work if i were also asked to generate it given mean. What i
>am trying to do is to generate jobs in an exponentially distributed
>fashion given the mean.

>like "The inter-arrival time of jobs is exponentially distributed with
>mean of ...".

>> >I was trying to find out the function in 'C' that would return me the
>> >exponential distribution value, given lambda as the argument. Can you

>> Let uniform() be your favorite random number generator that returns
>> a random float/double in the range  0.0 < uniform() < 1.0.

>> Then I think -lambda*log(uniform()) will be exponentially distributed.
>> At least that is what some old code of my does.

bellenot 3289> maple
|\^/|     Maple 6 (SUN SPARC SOLARIS)
._|\|   |/|_. Copyright (c) 2000 by Waterloo Maple Inc.
<____ ____>  Waterloo Maple Inc.
|       Type ? for help.
Quote:> assume(lambda>0);
> int(exp(-x/lambda),x=0..infinity);

lambda~

Quote:> int(exp(-x/lambda)/lambda,x=0..infinity);

1

Quote:> # So the density is exp(-x/lambda)/lambda -- compute the mean
> int(x*exp(-x/lambda)/lambda,x=0..infinity);

bytes used=1000248, alloc=851812, time=0.16
lambda~

Quote:> # Solve for -lambda*log(uniform())
> solve(P=int(exp(-x/lambda)/lambda,x=0..T),T);

-ln(-P + 1) lambda~

So lambda is the mean in this case.
--
http://www.math.fsu.edu/~bellenot
bellenot <At/> math.fsu.edu
+1.850.644.7189 (4053fax)