Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9182871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:39:59+00:00 2026-06-17T18:39:59+00:00

Am a newcomer to R and need advice on how to draw random numbers

  • 0

Am a newcomer to R and need advice on how to draw random numbers from a limited area of a Pareto Distribution with parameters s & beta. (System: Windows 7, R 2.15.2.)

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

For these data the parameters s & beta of a Pareto distribution are estimated following https://stats.stackexchange.com/questions/27426/how-do-i-fit-a-set-of-data-to-a-pareto-distribution-in-r

pareto.MLE <- function(X)
{
n <- length(X)
m <- min(X)
a <- n/sum(log(X)-log(m))
return( c(m,a) ) 
}

(2) Now I need to draw as many random numbers (RndNew) von this Pareto distribution (s, beta, see (1)) as there are observations (= data points: data$tx) . For the draw the area from which random numbers are drawn must be limited to the area where RndNewx >= data$tx; in other words: RndNewx must never be smaller than the corresponding data$tx.

Question: how to tell R to restrict the area of a Pareto distribution from which to draw a random number to be RndNewx >= data$tx?

Thanks a million for any help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:40:00+00:00Added an answer on June 17, 2026 at 6:40 pm

    The standard approach to sampling from a truncated distribution has three steps. Here’s an example with the normal distribution so you can get the idea.

    n <- 1000
    lower_bound <- -1
    upper_bound <- 1
    

    Apply the CDF to your lower and upper bounds to find the quantiles of the edges of your distribution.

    (quantiles <- pnorm(c(lower_bound, upper_bound)))
    # [1] 0.1586553 0.8413447
    

    Sample from a uniform distribution between those quantiles.

    uniform_random_numbers <- runif(n, quantiles[1], quantiles[2])
    

    Apply the inverse CDF.

    truncated_normal_random_numbers <- qnorm(uniform_random_numbers)
    

    truncated normal random numbers


    The CDF for the pareto distribution is

    ppareto <- function(x, scale, shape)
    {
      ifelse(x > scale, 1 - (scale / x) ^ shape, 0)
    }
    

    And the inverse is

    qpareto <- function(y, scale, shape)
    {
      ifelse(
        y >= 0 & y <= 1,
        scale * ((1 - y) ^ (-1 / shape)),
        NaN
      )
    }
    

    We can rework the above example to use these Pareto functions.

    n <- 1000
    scale <- 1
    shape <- 1
    lower_bound <- 2
    upper_bound <- 10
    
    (quantiles <- ppareto(c(lower_bound, upper_bound), scale, shape))
    uniform_random_numbers <- runif(n, quantiles[1], quantiles[2])    
    truncated_pareto_random_numbers <- qpareto(uniform_random_numbers, scale, shape)
    

    truncated Pareto distrbution


    To make it easier to reuse this code, we can wrap it into a function. The lower and upper bounds have default values that match the range of the distribution, so if you don’t pass values in, then you’ll get a non-truncated Pareto distribution.

    rpareto <- function(n, scale, shape, lower_bound = scale, upper_bound = Inf)
    {
      quantiles <- ppareto(c(lower_bound, upper_bound), scale, shape)
      uniform_random_numbers <- runif(n, quantiles[1], quantiles[2])    
      qpareto(uniform_random_numbers, scale, shape)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a newcomer to Python and is in need of programming a simple
Newcomer to Objective C and trying to translate concepts and sytax I know from
As a newcomer to PHP, I need to get $_SESSION variables working as part
Goal: Show data from server in wxPython GUI on client Newcomer to Twisted. I
Alright folks, I am a newcomer to Data Services and LINQ in desperate need
I am a newcomer to tcl/tk and need to run a script in cadence's
I'm a newcomer to Qt, but I'm trying to implement what basically amounts to
I am a newcomer to Maven, and I was wondering if there was a
As a newcomer to iOS, I found that ARC has thus far really helped
I'm a newcomer to Caliburn.Micro and there are a few things I'm still not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.