Thursday, February 23, 2006

 

Get Exponential RV from Uniform one

I was required to get a Exponential RV from Uniform One and I have found this equation

E=-log(U)*lamda

where U is the uniform RV and E is the Exponential RV,and lamda is the 1/(mean of the exponential rv) to get more info about Exponential RV check here.

For the C code
#include < stdlib.h >
#include < math.h >
float exp(float lamda)
{
return (-log10(Rand())*lamda);
}


Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?