[R] transform one probability distribution into another

Greg Snow 538280 at gmail.com
Mon Nov 4 21:35:10 CET 2013


As a general rule, the distribution functions that start with p (e.g.
pnorm, pexp, pgamma, ...) will transform a random variable from the
corresponding distribution to a uniformly distributed random variable.
 The functions that start with q (e.g. qnorm, qexp, qgamma, ...) will
transform a uniform random variable to the corresponding distribution.
 So going via the uniform distribution you can convert any
distribution to another one (provided the functions exist and you have
the correct one to begin with).  If there is not a built in function
for your distribution then you can create the appropriate
distributions from the cumulative distribution function and the
inverse cumulative distribution function  (the distr package and
friends could be of help).

But in practice if you just want to generate data from a distribution
you should look at the r functions (rnorm, rexp, regamma, ...).

On Mon, Nov 4, 2013 at 12:14 PM, b. alzahrani <cs_2002 at hotmail.com> wrote:
>
> Hi guys
>
> Given a exponential curve, is there any function on r that can generate exponential distributed random numbers?
>
> in General I want an function that can transform one probability distribution into another??
>
> Regards
> ******************************************************************
> Bander
>  *************************************
>
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com



More information about the R-help mailing list