# Four-parameter beta distribution

**URL:** <https://discourse.julialang.org/t/four-parameter-beta-distribution/90280>\
**Category:** Statistics\
**Created:** [November 15, 2022, 9:50am UTC](https://discourse.julialang.org/t/four-parameter-beta-distribution/90280 "2022-11-15T09:50:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Igor\_Douven](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/igor_douven/32/8433_2.png) [@Igor\_Douven](https://discourse.julialang.org/u/Igor_Douven)\
**Post date:** [November 15, 2022, 9:50am UTC](https://discourse.julialang.org/t/four-parameter-beta-distribution/90280/1 "2022-11-15T09:50:54Z")

</div>

Hi all,

The standard Beta distribution has as support the [0, 1] interval. However, there is also a four-parameter version, which allows one to specify an arbitrary minimum and maximum. R has the function `Beta_ab` for this. I can’t find a Julia equivalent in the `Distributions.jl` package. Does anyone know whether such an equivalent exists?

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [November 15, 2022, 11:13am UTC](https://discourse.julialang.org/t/four-parameter-beta-distribution/90280/2 "2022-11-15T11:13:50Z")

</div>

I don’t know (and wouldn’t know). Yes, it doesn’t seem to be in that package. I looked at the code and docs, and realized there’s e.g. a Noncentralbeta distribution, and looking up beta didn’t find it. At first I thought it missing from the docs, but searching for a prefix like “non” finds that. “Four” didn’t find what you want.

Looking at the formula, and knowing it’s a simple transformation, I’m not sure it would be that difficult to make:

> **[Beta\_ab function - RDocumentation](https://www.rdocumentation.org/packages/ExtDist/versions/0.6-4/topics/Beta_ab)**
>
> \<p\>Density, distribution, quantile, random number
> generation, and parameter estimation functions for the 4-parameter beta distribution.
> Parameter estimation can be based on a weighted or unweighted i.i.d sample and can be performed
> numerically.\</p\>

I thought Distributions.jl was extremely good, with almost everything under the sun (and I really want Julia, and that package, to be as good as possible, as an R replacement). There are however a lot of distributions out there.

At least you can call all R code with RCall.jl (it also has an R mode), so would that be helpful (enough), as a workaround?

I didn’t look at the R code itself (it’s also GPL, and I know people even avoid looking if they want to translate). I don’t think you actually need to look.

---

<div class="post-metadata">

**Author:** ![Igor\_Douven](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/igor_douven/32/8433_2.png) [@Igor\_Douven](https://discourse.julialang.org/u/Igor_Douven)\
**Post date:** [November 15, 2022, 11:41am UTC](https://discourse.julialang.org/t/four-parameter-beta-distribution/90280/3 "2022-11-15T11:41:34Z")

</div>

Thank you. It’s unfortunate. Yes, I could use `RCall.jl`, but then I don’t think I could use the distribution as input for a mixture distribution (which is what I need).

---

<div class="post-metadata">

**Author:** ![Igor\_Douven](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/igor_douven/32/8433_2.png) [@Igor\_Douven](https://discourse.julialang.org/u/Igor_Douven)\
**Post date:** [November 15, 2022, 11:57am UTC](https://discourse.julialang.org/t/four-parameter-beta-distribution/90280/4 "2022-11-15T11:57:48Z")

</div>

I’m not very familiar with `Distributions.jl`, but from some experimenting I just did with the package I think it is safe to assume that the four-parameter distribution \mathrm{Beta}(\alpha, \beta, a, b), with support [a, b], can be defined in terms of the standard Beta distribution as (b - a) \times \mathrm{Beta}(\alpha, \beta) + a. (Please correct me if wrong.)

```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:** [November 15, 2022, 1:22pm UTC](https://discourse.julialang.org/t/four-parameter-beta-distribution/90280/5 "2022-11-15T13:22:04Z")

</div>

According to wikipedia that is correct. [Beta distribution - Wikipedia](https://en.wikipedia.org/wiki/Beta_distribution#Four_parameters)

Just remember that the moments will also shift as a result (mean is no longer simply \alpha / (\alpha + \beta)).

---

<div class="post-metadata">

**Author:** ![Igor\_Douven](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/igor_douven/32/8433_2.png) [@Igor\_Douven](https://discourse.julialang.org/u/Igor_Douven)\
**Post date:** [November 15, 2022, 1:40pm UTC](https://discourse.julialang.org/t/four-parameter-beta-distribution/90280/6 "2022-11-15T13:40:13Z")

</div>

Thank you for confirming.

---

<div class="post-metadata">

**Author:** ![gaballench](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gaballench/32/212238_2.png) [@gaballench](https://discourse.julialang.org/u/gaballench)\
**Post date:** [February 12, 2025, 11:21am UTC](https://discourse.julialang.org/t/four-parameter-beta-distribution/90280/7 "2025-02-12T11:21:57Z")

</div>

I know this question is two-years-old, but just for reference there is the [StratIntervals.jl](https://github.com/gaballench/StratIntervals.jl) package which provides the Four-Parameter Beta distribution.
