ddweibull: The type 1 discrete Weibull distribution

Description Usage Arguments Details Value Author(s) Examples

Description

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

Usage

1
2
3
4
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

Details

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

Value

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

Author(s)

Alessandro Barbiero

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 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)

Example output

Loading required package: Rsolnp
 [1] 0.40000000 0.18909740 0.11866347 0.07967971 0.05550770 0.03961701
 [7] 0.02877831 0.02119190 0.01577790 0.01185488
[1] 16
[1] 0.9908525
 [1] 0.400000000 0.189097397 0.118663474 0.079679712 0.055507700 0.039617011
 [7] 0.028778312 0.021191898 0.015777899 0.011854881 0.008976778
[1] 15
[1] 0.9908525
 [1] 0.57 0.18 0.08 0.08 0.02 0.02 0.01 0.00 0.01 0.02 0.01
 [1] 0.600000000 0.174293249 0.087229935 0.049386598 0.029894854 0.018908549
 [7] 0.012346468 0.008261763 0.005638307 0.003911069 0.002750606

DiscreteWeibull documentation built on May 2, 2019, 8:58 a.m.