exponential distribution function given lambda in C

exponential distribution function given lambda in C

Post by vrk19 » Fri, 22 Nov 2002 10:45:24



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
please help me get to know the same.

Thanks a lot for your time.

Ramakrishnan V

 
 
 

exponential distribution function given lambda in C

Post by Steve Bellen » Fri, 22 Nov 2002 11:55:11




>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
>please help me get to know the same.

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

Post by vrk19 » Sat, 23 Nov 2002 01:21:12


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
> >please help me get to know the same.

> 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

Post by Steve Bellen » Sat, 23 Nov 2002 04:48:13




>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
>> >please help me get to know the same.

>> 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.
 \  MAPLE  /  All rights reserved. Maple is a registered trademark of
 <____ ____>  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)