Re: [R] How can I simulate Pareto distribution in R?
On Sun, Jan 09, 2005 at 12:21:47AM -0800, Ni Xiao wrote: > Hi, guys, >I need to simulate Pareto distribution. But I found 'rpareto' didn't exist > in R. And it seems that Pareto distribution don't have mathematical > relationships with other distributions. What can I do? Well, it has a relation to the uniform distribution thru F(X) = U ~ uniform(0, 1), where X is Pareto with cdf F. Solve for X and you have just reinvented the "inverse method" of generating random numbers from a cdf F. Remigijus made that explicit for you. -- Göran Broströmtel: +46 90 786 5223 Department of Statistics fax: +46 90 786 6614 Umeå University http://www.stat.umu.se/egna/gb/ SE-90187 Umeå, Sweden e-mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How can I simulate Pareto distribution in R?
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 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] How can I simulate Pareto distribution in R?
Hi, guys, I need to simulate Pareto distribution. But I found 'rpareto' didn't exist in R. And it seems that Pareto distribution don't have mathematical relationships with other distributions. What can I do? Thanks a lot. Ni - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html