Qasim Ramzan
Qasim Ramzan

Reputation: 1

Generating Samples from Customized Distribution - Stuck with Range Limitation

I'm struggling to generate samples from a custom distribution defined by its CDF but facing a persistent limitation. The issue boils down to:

Limited Range of Samples: Despite having a theoretical range of 0 to infinity, my function only produces samples within a very narrow range, typically close to 2.5 in my case. I've tried adjusting various parameters (phi1, gam, del) and even expanding the search range for the uniroot function, but haven't achieved the desired spread.

Specific Function and Code:

Here's the core function and example code for illustrative purposes:

sim.g <- function(n, phi1, gam, del) {
  CDF <- function(t, phi, gamma, delta) {
    return(1 - exp(-phi * t^gamma * exp(delta * t)))
  }
  quantile_function <- function(p, phi, gamma, delta) {
    f <- function(t) CDF(t, phi, gamma, delta) - p
    root <- uniroot(f, c(0, 10000))
    return(root$root)
  }
  T1 <- c(rep(0, n))
  for (i in 1:n) {
    u <- runif(1)
    T1[i] <- quantile_function(u, phi1, gam, del)
  }
  print(T1)
}
sim.g(n = 30, phi1 = 0.1, gam = 1.5, del = 4)

What techniques or adjustments could help overcome this range limitation and generate samples across the intended range (0 to 100 in my case)?

Any insights or guidance on tackling this challenge would be greatly appreciated!

Thank you in advance for your expertise and support!

Upvotes: 0

Views: 48

Answers (0)

Related Questions