0

I am trying to randomly select values between 2 points so that the most likely ones are selected closer to the left boundary and decrease linearly over the range.

Like this but so that values closer to the min and more likely than ones closer to the max

runif(1, min=11700, max=126000)
user3651829
  • 821
  • 1
  • 7
  • 12
  • 1
    These posts may help, but you will need to formalize your distribution more first: https://stackoverflow.com/questions/41325459/generate-random-number-from-custom-distribution, https://stats.stackexchange.com/questions/12843/generating-random-samples-from-a-custom-distribution, https://stackoverflow.com/questions/28627487/how-do-i-sample-from-a-custom-distribution – emilliman5 Jun 23 '17 at 13:26
  • You need to create a custom random number generator because `runif` generates random sample from a uniform distribution. – A Gore Jun 23 '17 at 13:27
  • Yes, I have looked at those already, but I thought given that I want it to decrease linearly over the range it would be more straight forward – user3651829 Jun 23 '17 at 13:45
  • decrease linearly over the range. How to you visualize the function? – amonk Jun 23 '17 at 13:56
  • Like a right-angled triangle – user3651829 Jun 23 '17 at 14:02

1 Answers1

0

You can use the beta distribution and then scale up the values to get a 'lefty' distribution

fun <- function(n) {
  11700 + (126000 - 11700) * rbeta(n, 1, 3) # a < b will tilt left 
}

hist(fun(1000))
Dirk Nachbar
  • 542
  • 4
  • 16