# \[ANN\] BulkAndTails.jl

**URL:** <https://discourse.julialang.org/t/ann-bulkandtails-jl/72310>\
**Category:** Package Announcements\
**Created:** [November 30, 2021, 4:09pm UTC](https://discourse.julialang.org/t/ann-bulkandtails-jl/72310 "2021-11-30T16:09:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlkrock](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlkrock/32/31211_2.png) [@mlkrock](https://discourse.julialang.org/u/mlkrock)\
**Post date:** [November 30, 2021, 4:09pm UTC](https://discourse.julialang.org/t/ann-bulkandtails-jl/72310/1 "2021-11-30T16:09:05Z")

</div>

Hello. I’ve just registered [BulkAndTails.jl](https://github.com/mlkrock/BulkAndTails.jl), which offers an interface for the seven-parameter Bulk-And-Tails (BATs) distribution in the style of [Distributions.jl](https://github.com/JuliaStats/Distributions.jl). BATs was recently introduced in [Stein 2021](https://onlinelibrary.wiley.com/doi/abs/10.1002/env.2658) to model an entire univariate distribution when extremes (i.e., tails) are of interest. Traditional methods for extremes, such as `Distributions.GeneralizedPareto` or `Distributions.GeneralizedExtremeValue`, ignore the bulk (i.e., nonextremes) of the data, and separate analyses must be performed for the upper and lower tails. BATs is a model for the entire distribution with flexible behavior in both tails.

BATs has seven parameters (\kappa\_0, \tau\_0, \phi\_0, \kappa\_1, \tau\_1, \phi\_1, \nu) where the 0 subscript controls lower tail behavior and 1 subscript controls upper tail behavior. \kappa is a shape parameter controlling the tail behavior:

- \kappa\<0 \implies bounded tail
- \kappa = 0 (defined by continuity) \implies Gaussian tail
- \kappa\>0 \implies heavy tail

\tau\>0 and \phi are scale and location parameters, respectively. The BATs cdf is T\_\nu(H\_\theta(x)), where T\_\nu is the student-t cdf with \nu degrees of freedom and H\_\theta is a monotone-increasing function depending upon the other parameters besides \nu. Therefore the pdf is t\_\nu(H\_\theta(x)) H'\_\theta(x) where t\_\nu is the student-t pdf with \nu degrees of freedom.

Some other key features of BATs:

- can behave like any three-parameter generalized Pareto distribution in either tail
- closed form density (no unknown normalizing constant)
- analytic density (with respect to argument x and seven parameters) on the interior of its support. We use `ForwardDiff.jl` and `Ipopt.jl` for maximum likelihood estimation.

Another dependency is `Roots.jl` for the quantile (and sampler) function. These dependencies will make absorption into `Distributions.jl` difficult, but again, the functions in this package match how functions in `Distributions.jl` are called. See the example file for a demonstration.

Thanks to @cgeoga for the initial implementation of this package and much assistance with learning Julia.

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [December 1, 2021, 1:36pm UTC](https://discourse.julialang.org/t/ann-bulkandtails-jl/72310/2 "2021-12-01T13:36:49Z")

</div>

Are there no analytical expressions for the moments?

---

<div class="post-metadata">

**Author:** ![mlkrock](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlkrock/32/31211_2.png) [@mlkrock](https://discourse.julialang.org/u/mlkrock)\
**Post date:** [December 1, 2021, 10:04pm UTC](https://discourse.julialang.org/t/ann-bulkandtails-jl/72310/3 "2021-12-01T22:04:30Z")

</div>

Hey @tbeason ! No expressions for the moments here, and no guarantee that they will exist, as this family of distributions includes the student-t family, in particular the Cauchy distribution.
