knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
The name of this R package "dhh" can be understood as "Distributions with Heavy Heads". The probability density function of the heavy-headed distribution is
$$f(x) = \frac{\alpha (b-a)^{-\alpha}}{(x-a)^{1-\alpha}}I{a
This package contains four functions on a heavy-headed distribution:
dhh
: the probability density functionphh
: the cumulative distribution function (CDF)qhh
: the quantile functionrhh
: the random variablesNext, I will introduce these functions with examples.
To use this library, we can first install it and then use the following command.
library(dhh)
dhh
This function dhh(x, a, b, alpha)
gives the values of the density of the heavy-headed distribution.
The default values of a
, b
and alpha
are 0
, 1
and 0.1
, respectively. Then, the following two commands give the same result, the value of the density at 0.5
.
dhh(0.5) dhh(0.5, 0, 1, 0.1)
The argument x
can be a vector.
dhh(c(0.5, 0.7))
We can take a look at the plots of some density functions.
curve(dhh(x, a=0, b=1, alpha=0.1), -1, 2) curve(dhh(x, a=0, b=10, alpha=0.1), -1, 11)
phh
This function phh(x, a, b, alpha)
gives the values of the CDF of the heavy-headed distribution.
The default values of a
, b
and alpha
are 0
, 1
and 0.1
, respectively. Then, the following two commands give the same result, the value of the density at 0.5
.
phh(0.5) phh(0.5, 0, 1, 0.1)
The argument x
can be a vector.
phh(c(0.5, 0.7))
We can take a look at the plots of some CDF's.
curve(phh(x, a=0, b=1, alpha=0.1), -1, 2) curve(phh(x, a=0, b=10, alpha=0.1), -1, 11)
qhh
This function qhh(p, a, b, alpha)
gives the quantiles of the heavy-headed distribution.
The default values of a
, b
and alpha
are 0
, 1
and 0.1
, respectively. Then, the following two commands give the same result, the value of the density at 0.5
.
qhh(0.9) qhh(0.9, a=0, b=1, alpha=0.1)
The argument p
can be a vector.
phh(qhh((1:9)/10))
We can take a look at the plots of some quantile functions.
curve(qhh(x, 0, 1, 0.1), from = 0.1, to = 0.9) curve(qhh(x, a=10, b=100, alpha = 0.1), from = 0.1, to = 0.9)
rhh
This function rhh(n, a, b, alpha1)
generate $n$ i.i.d. random variables following the heavy-headed distribution.
The default values of a
, b
and alpha
are 0
, 1
and 0.1
, respectively. Then, the following two commands are the same.
rhh(5) rhh(5, a = 0, b = 1, alpha = 0.1)
We can generate $10000$ i.i.d. random variables and plot the histogram. Then we can add the density plot.
hist(rhh(10000), freq=FALSE) curve(dhh, add = TRUE, col = 2)
We can also check the fact that the density goes to infinity as a
goes to a
.
dhh(c(0.1, 0.01, 0.001, 0.0001, 0.00001))
Runlong Tang (2018) A Note On Finite Moments, Rediscovery Of The Pareto Distribution and Distributions With Heavy Tails and Heads (v1) https://sites.google.com/site/tangrunlong/notes-on-finance
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.