I wanted to know how do I calculate exact values for Weibull distribution in R.

For example, say $X$ ~ Weibull(3,5), and I want to calculate $P(X\gt 7)$. How do I do that? I want to estimate $P(X\gt 7)$ based on a sample size of, say, $n=300.$

  • 1
    $\begingroup$ Is you sample censored or not? $\endgroup$
    – whuber
    Nov 15 '15 at 15:05

The answer is simply (it depends on your notation and what is shape and what is scale)

pweibull(7, shape = 3, scale = 5, lower.tail = FALSE)

Relating to your comment, the answer does not depend on sample size. It does not matter if you draw one observation, 50, 300, or 1000, the probability will be the same. Weibull CDF is a function describing probability of observing some value, it does not depend on sample size. If we are able to sample from it properly (and we are), than the samples we obtain should follow the distribution and so the probabilities of observing certain values in the samples should follow the probabilities known from the Weibull CDF function. You can check this by simple simulation

# draw single value 1000 times
> mean(replicate(1000, rweibull(1, 3, 5)>7))
[1] 0.064

# draw 300 values 1000 times
> mean(replicate(1000, rweibull(300, 3, 5)>7))
[1] 0.06405

The values sampled are independent and identically distributed, so it also does not matter if you draw 1 value 1000 times or 1000 values at once, the result in the long run will be the same.

1-pweibull(p = 7,shape = 5,scale = 3)

If 3 is the scale and 5 is the shape. Be careful with which is scale and which is shape.


  • $\begingroup$ Thank you! Also, if I want to do this for n samples, do I need to write a function for it? $\endgroup$
    – Pip
    Nov 15 '15 at 6:20
  • $\begingroup$ What do you mean? If X~Weibull(3,5), then P(X>7) is a known value. What's the purpose of sampling multiple time? To estimate P(X>7)? $\endgroup$
    – WCMC
    Nov 15 '15 at 7:04
  • $\begingroup$ Sorry, I should've made myself clearer. I want to estimate P(X>7) based on a sample size of, say, n=300. $\endgroup$
    – Pip
    Nov 15 '15 at 7:31
  • $\begingroup$ Please see my updated answer. Does it answer your question? $\endgroup$
    – WCMC
    Nov 15 '15 at 7:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.