Weibull Distribution in R

Weibull Distribution in R, Weibull Distribution was discovered by Swedish physicist Wallodi Weibull in 1939.

A continuous random variable X is said to follow Weibull distribution if its probability density function

fx(x; α, β)= α/βα [x α-1e(-x/ β)^α]

For x>0, α, β>0.

There are two parameters in this distribution and It can be used in reliability theory. Corrosion, alloy weight loss, and metal tensile strength all follow the Weibull distribution.

How to Calculate Mahalanobis Distance in R »

Weibull Distribution in R

Let’s see how to plot Weibull distribution in R.

Syntax:-

dweibull(x, shape, scale = 1) to create the probability density function.
curve(function, from = NULL, to = NULL) to plot the probability density function.

Weibull distribution based on parameters shape = 2 and scale = 2 where the x-axis of the plot ranges from 0 to 5:

A specific instance of the generalized gamma distribution is the Weibull distribution.

How to Plot Categorical Data in R-Quick Guide »

curve(dweibull(x, shape=2, scale = 2), from=0, to=5)

Let’s make it aesthetically appealing better,

curve(dweibull(x, shape=2, scale = 2), from=0, to=5,
    main = 'Weibull Distribution (shape = 2, scale = 2)',
    ylab = ' dWeibull gives the density',
    lwd = 2,
    col = 'pink')

Let’s see how to add more than one curve in the same plot

Goodness of Fit Test- Jarque-Bera Test in R »

curve(dweibull(x, shape=2, scale = 2), from=0, to=5,
    main = 'Weibull Distribution',
    ylab = ' dWeibull gives the density',
    lwd = 2,
    col = 'pink')
curve(dweibull(x, shape=1.5, scale = 2), from=0, to=5, col='green', add=TRUE)

We can add a legend to the plot by using the legend() function,

legend(2, .3, legend=c("shape=2, scale=2", "shape=1.5, scale=2"),
       col=c("green", "blue"), lty=1, cex=1.2)

Additional Info

The density is given by dWeibull, the distribution function is given by pWeibull, the quantile function is given by qWeibull, the random deviates are generated by rWeibull, and the distribution parameters are estimated by eWeibull. The log-likelihood function is provided by lWeibull.

What all Data Science Soft Skills Required? »

You may also like...

Leave a Reply

Your email address will not be published.

5 × 1 =

error

Subscribe Now