In page 22 of chapter 6, I see a R snippet stating, we can define the aforementioned functions from first principles and the author went on to put up the equations. rweibull: (log(1-runif(n))/c) ^ (1/g) qweibull: (log(1-p)/c) ^ (1/g) I understand the other two pweibull and dweibull. (I understand runiform gives samples from uniform distribution. I just need to understand the concept here as how he/she arrived at this.) If any one can guide me to a source or help me understand the derivation, it would be great. TIA
One way of generating a random sample from a distribution is to generate a random sample from a Uniform(0,1) distribution and put those numbers into the inverse of the required CDF. (The CDF has range 0->1 and the inverse of the CDF takes the values in that range generated by the random Uniform sample and turns it into a random sample from the required distribution). To read more about it see the following link: https://en.wikipedia.org/wiki/Inverse_transform_sampling Hence the rweibull is taking a random sample from the Uniform distribution and putting into the inverse of the Weibull CDF (rearrange the CDF to get in terms of x). That being said, I think it should be dividing by minus c not just c (or put the minus somewhere else in that step). The q function is similar in that it is also using the inverse of the CDF. The CDF takes a number c and turns it into the probability P(X <= c). The q function takes probabilities and outputs the value of c, i.e. it is just the inverse of the Weibull CDF. However I think that again a minus sign is missing.