Learn R Programming

DiscreteWeibull (version 1.1)

Discrete Weibull (Type 1): The type 1 discrete Weibull distribution

Description

Probability mass function, distribution function, quantile function and random generation for the discrete Weibull distribution with parameters $q$ and $\beta$

Usage

ddweibull(x, q, beta, zero = FALSE) pdweibull(x, q, beta, zero = FALSE) qdweibull(p, q, beta, zero = FALSE) rdweibull(n, q, beta, zero = FALSE)

Arguments

x
vector of quantiles
p
vector of probabilities
q
first parameter
beta
second parameter
zero
TRUE, if the support contains $0$; FALSE otherwise
n
sample size

Value

ddweibull gives the probability function, pdweibull gives the distribution function, qdweibull gives the quantile function, and rdweibull generates random values.

Details

The discrete Weibull distribution has probability mass function given by $P(X=x;q,\beta)=q^{(x-1)^{\beta}}-q^{x^{\beta}}$, $x=1,2,3,\ldots$, if zero=FALSE; or $P(X=x;q,\beta)=q^{x^{\beta}}-q^{(x+1)^{\beta}}$, $x=0,1,2,\ldots$, if zero=TRUE. The cumulative distribution function is $F(x;q,\beta)=1-q^{x^{\beta}}$ if zero=FALSE; $F(x;q,\beta)=1-q^{(x+1)^{\beta}}$ otherwise

Examples

Run this code
# Ex.1
x <- 1:10
q <- 0.6
beta <- 0.8
ddweibull(x, q, beta)
t <- qdweibull(0.99, q, beta)
t
pdweibull(t, q, beta)
# 
x <- 0:10
ddweibull(x, q, beta, zero=TRUE)
t <- qdweibull(0.99, q, beta, zero=TRUE)
t
pdweibull(t, q, beta, zero=TRUE)

# Ex.2
q <- 0.4
beta <- 0.7
n <- 100
x <- rdweibull(n, q, beta)
tabulate(x)/sum(tabulate(x))
y <- 1:round(max(x))
# compare with
ddweibull(y, q, beta)

Run the code above in your browser using DataLab