Hi

I am assuming that 0 < r < 1. Then your density should just be f(r) = 2r.
The cdf is then F(r) =  r^2. You can use the beta(a=2, b=1) or
the inverse method: R = sqrt(U) where  U ~ Uniform(0,1).

If you really want your density to be exactly f( r ) = 2*pi*r, then you must
have 0 < r < 1 / sqrt( pi ).
The cdf is then F(r) = pi*(r^2). Again, you can generate a value from the
beta(a=2,b=1) and divide that value by sqrt(pi)
or you can use the inverse method: R = sqrt( U / pi ) where  U ~
Uniform(0,1).

Please check the properties of a pdf.

Hope that helps you.

On Thu, May 6, 2010 at 11:45 PM, Lucas Rodrigues de Paula <
[email protected]> wrote:

> Please, I need to generate a linear probability density function like this
> f( r ) = 2 ( pi )r, but I can't. I'm trying using the gsl_ran_beta
> function,
> with a = 2 and b = 1, but gsl_ran_beta becomes f( r ) = 2r. How can I get
> f(
> r ) = 2( pi )r ?
>
>
_______________________________________________
Help-gsl mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gsl

Reply via email to