问题
I have to simulate a system's fail times, to do so I have to use the Weibull distribution with a "decreasing hazard rate" and a shape of "0.7-0.8". I have to generate a file with 100 results for the function that uses random numbers from 0 to 1.
So I've been searching a bit and I found this R function:
pweibull(q, shape, scale = 1, lower.tail = T, log.p = F)
There are some other (rweibull,qweibull...) but I think this is the one that I have to use, since is the cumulative distribution one, as the exercise statement says. The problem is that I am new to R and that I don't really know what parameters I have to pass to this function.
I'm guessing shape should be 0.7-0.8, and scale 1. For q parameter, should I create a random vector of 100 numbers with 0 to 1 values? If so, any tip of how to do it? Also any tip on how to export the resultant data to a file?
回答1:
I'm not sure what the question is, but if you want to generate 100 values drawn from Weibull distribution with shape parameter of 0.75 use rweibull(100, 0.75)
.
If you want to see what the probability is that they are larger than zero, use pweibull(rweibull(100, 0.75), 0.75)
.
You should also be aware that there is a general no-homework rule on these sites.
来源:https://stackoverflow.com/questions/17768765/use-the-cumulative-distribution-function-of-weibull-in-r