[R] How can I simulate Pareto distribution in R?

Remigijus Lapinskas remigijus.lapinskas at mif.vu.lt
Sun Jan 9 10:50:28 CET 2005


If you define Pareto density as p(x)=c*x^(-(c+1)) for x>1, then

dpareto <- function(x,c){
if(c<=0)stop("c must be positive") # Diagnostic step
ifelse(x<1,0,c/x^(c+1))}

ppareto <- function(q,c){
if(c<=0)stop("c must be positive > 0")
ifelse(q<1,0,1-1/q^c)}

qpareto <- function(p,c){
if(c<=0) stop("c must be positive > 0")
if(any(p<0)|any(p>1)) # Symbol | denotes logical OR
stop("p must be between 0 and 1")
q <- (1-p)^(-1/c)
q}

rpareto <- function(n,c){
if(c<=0) stop("c must be positive")
rp <- runif(n)^(-1/c)
rp}

Good luck,
Rem

Sunday, January 9, 2005, 10:21:47 AM, you wrote:

NX> Hi, guys,
NX>    I need to simulate Pareto distribution. But I found
NX> 'rpareto' didn't exist in R. And it seems that Pareto distribution
NX> don't have mathematical relationships with other distributions.
NX> What can I do?
 
NX> Thanks a lot.
 
NX> Ni




More information about the R-help mailing list