addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwchatcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgoogleimageimagesinstagramlinklocation-pinmagnifying-glassmailminusmoremuplabelShape 3 + Rectangle 1outlookpersonplusprice-ribbonImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruseryahoo

Bay Area useR Group (R Programming Language) Message Board Bay Area useR Group (R Programming Language) Discussion Forum › random number from truncated pareto distribution

random number from truncated pareto distribution

A former member
Post #: 1
Dear R professionals,

am a newcomer to R, and greatful for any advice and help concerning the following problem:

(1) I have data in a vector data$T; each single data point I'll call data&tx

(2) for these data I estimate the parameters s & beta of an pareto distribution following >http://stats.stackexc...­

pareto.MLE <- function(X)
n <- length(X)
m <- min(X)
a <- n/sum(log(X)-log(m))
return( c(m,a) )
par.eto.par <- c(s=pareto.MLE(data$T)[2], beta=pareto.MLE(data$T)[1])

(3) Currently I created a loop to iterate the random draw from the total area of the Pareto distribution

random <- rpareto(l, location=beta, shape=s)

until all randomly drawn numbers (i.e. random) >= data$tx
because this is the only line I found to draw random samples from a Pareto distribution.
This loop however is inefficient and needs a lot of time to complete.

(4) Hence, what I need is to restrict the area of the Pareto Distribution with parameters estimated in (2) such that the random numbers >= data$tx .

But I cannot find any possibility how to tell R to do the random draw from a somehow truncated area of the Pareto distribution.

Below I give arbitrary, few values, just to provide an 'image' what I need.

(a) Let say data$T is (1;4;10;100;12000)
(b) random numbers to be drawn from truncated Pareto distribution with Parameter s & beta could then look like random$T(1;6;120;100;130023).
But: there must never occur a number in random$T that is smaller than the value in data$T (1;4;10;100;12000) at the corresponding location.

Does anyone know how to program in R a "restriction" to a distribution e.g. Pareto from where to draw random numbers?

Thanks for any ideas and advice!!
Cheers, Lucie

PS: versions/system used are R 2.15.1 running on Windows 7, 64 bit
A former member
Post #: 2
Richie Cotton (­) explained, how to solve this problem.

If you need to solve the same problem (even if you use a different distribution) or if you are simply interested in the answer, you'll find his explanations at:


Good luck!
Powered by mvnForum

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy