using Distributions
using StatsPlots
plot(Beta(1, 1), ylim=(0, 5), size=(400, 300), label=false, xlabel="x", ylabel="P(x)", title="Beta distribution shapes")
How does plot get the values of the Beta pdfunction to plot the graph.
In other words, if I wanted to calculate the value of f(x; a,b) for x=0.73 how could I do it, apart from going to the definition I find on Wikipedia.
And for the calculation of Beta(a,b), how do you do it?
I’m not sure I’m following - what is your issue? The title suggests you are interested in a pdf which suggests you are talking about a distribution, hence the initial answers you got relating to the Beta probability distribution. The beta function shares a name with and is used in the pdf of the Beta distribution but is not the same thing.
Nothing more than that.
I wanted to understand how plot could get the values to plot a particular beta pdf.
And since the constant B(a,b) is used in the definition of pdfbeta, I wanted to understand where and how it is calculated.
Doing @edit Beta(5,3) takes me inside the beta.jl module where I couldn’t find how the calculations of the pdf and the constant B(a,b) are done.
Now following your(s) instructions I found that it is calculated (inside SpecialFunctions.jl module, using C libraries
beta(x, y)
"""
Euler integral of the first kind ``\\operatorname{B}(x,y) = \\Gamma(x)\\Gamma(y)/\\Gamma(x+y)``.
"""
function beta(a::Number, b::Number)
lab, sign = logabsbeta(a, b)
return sign*exp(lab)
end
if Base.MPFR.version() >= v"4.0.0"
function beta(y::BigFloat, x::BigFloat)
z = BigFloat()
ccall((:mpfr_beta, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Ref{BigFloat}, Int32), z, y, x, ROUNDING_MODE[])
return z
end
end