Defined Types
We provide two new types that are subtypes of AbstractIMF, which itself is a subtype of Distributions.ContinuousUnivariateDistribution and generally follow the API provided by Distributions.jl. These are
InitialMassFunctions.AbstractIMF — TypeAbstract type for IMFs; a subtype of Distributions.ContinuousUnivariateDistribution, as all IMF models can be described as continuous, univariate PDFs.
InitialMassFunctions.BrokenPowerLaw — TypeBrokenPowerLaw(α::AbstractVector{T}, breakpoints::AbstractVector{S}) where {T <: Real, S <: Real}
BrokenPowerLaw(α::Tuple, breakpoints::Tuple)An AbstractIMF <: Distributions.ContinuousUnivariateDistribution that describes a broken power-law IMF with probability distribution
\[ \frac{dn(m)}{dm} = A \times m^{-\alpha}\]
that is defined piecewise with different normalizations A and power law slopes α in different mass ranges. The normalization constants A will be calculated automatically after you provide the power law slopes and break points.
Arguments
α; the power-law slopes of the different segments of the broken power law.breakpoints; the masses at which the power law slopes change. Iflength(α)=n, thenlength(breakpoints)=n+1.
Examples
BrokenPowerLaw([1.35,2.35],[0.08,1.0,Inf]) will instantiate a broken power law defined from a minimum mass of 0.08 to a maximum mass of Inf with a single switch in α at m=1.0. From 0.08 ≤ m ≤ 1.0, α = 1.35 and from 1.0 ≤ m ≤ Inf, α = 2.35.
Notes
There is some setup necessary for quantile and other derived methods, so it is more efficient to call these methods directly with an array via the call signature quantile(d::BrokenPowerLaw{T}, x::AbstractArray{S}) rather than broadcasting over x. This behavior is now deprecated for quantile(d::Distributions.UnivariateDistribution, X::AbstractArray) in Distributions.jl.
Methods
Base.convert(::Type{BrokenPowerLaw{T}}, d::BrokenPowerLaw)minimum(d::BrokenPowerLaw)maximum(d::BrokenPowerLaw)partype(d::BrokenPowerLaw)eltype(d::BrokenPowerLaw)mean(d::BrokenPowerLaw)median(d::BrokenPowerLaw)var(d::BrokenPowerLaw), may not function correctly for largemmaxskewness(d::BrokenPowerLaw), may not function correctly for largemmaxkurtosis(d::BrokenPowerLaw), may not function correctly for largemmaxpdf(d::BrokenPowerLaw,x::Real)logpdf(d::BrokenPowerLaw,x::Real)cdf(d::BrokenPowerLaw,x::Real)ccdf(d::BrokenPowerLaw,x::Real)quantile(d::BrokenPowerLaw{S},x::T) where {S,T<:Real}quantile!(result::AbstractArray,d::BrokenPowerLaw{S},x::AbstractArray{T}) where {S,T<:Real}quantile(d::BrokenPowerLaw{T},x::AbstractArray{S})cquantile(d::BrokenPowerLaw{S},x::T) where {S,T<:Real}rand(rng::AbstractRNG, d::BrokenPowerLaw,s...)- Other methods from
Distributions.jlshould also work becauseBrokenPowerLaw <: AbstractIMF <: Distributions.ContinuousUnivariateDistribution. For example,rand!(rng::AbstractRNG, d::BrokenPowerLaw, x::AbstractArray).
InitialMassFunctions.LogNormalBPL — TypeLogNormalBPL(μ::Real, σ::Real, α::AbstractVector{<:Real}, breakpoints::AbstractVector{<:Real})
LogNormalBPL(μ::Real, σ::Real, α::Tuple, breakpoints::Tuple)A LogNormal distribution at low masses, with a broken power law extension at high masses. This uses the natural log base like Distributions.LogNormal; if you have σ and μ in base 10, then multiply them both by log(10). Must have length(α) == length(breakpoints)-2. The probability distribution for this IMF model is
\[ \frac{dn(m)}{dm} = \frac{A}{x} \, \exp \left[ \frac{ -\left( \log(x) - \mu \right)^2}{2\sigma^2} \right]\]
for m < breakpoints[2], with a broken power law extension above this mass. See BrokenPowerLaw for interface details; the α and breakpoints are the same here as there.
Arguments
μ; see Distributions.LogNormalσ; see Distributions.LogNormalα; list of power law indices withlength(α) == length(breakpoints)-2.breakpoints; list of masses that signal breaks in the IMF. MUST BE SORTED and bracketed withbreakpoints[1]being the minimum valid mass andbreakpoints[end]being the maximum valid mass.
Examples
If you want a LogNormalBPL with a characteristic mass of 0.5 solar masses, log10 standard deviation of 0.6, and a single power law extension with slope α=2.35 with a break at 1 solar mass, you would do LogNormalBPL(log(0.5),0.6*log(10),[2.35],[0.08,1.0,Inf] where we set the minimum mass to 0.08 and maximum mass to Inf. If, instead, you know that log10(m)=x, where m is the characteristic mass of the LogNormal component, you would do LogNormalBPL(x*log(10),0.6*log(10),[2.35],[0.08,1.0,Inf].
Notes
There is some setup necessary for quantile and other derived methods, so it is more efficient to call these methods directly with an array via the call signature quantile(d::LogNormalBPL{T}, x::AbstractArray{S}) rather than broadcasting over x. This behavior is now deprecated for quantile(d::Distributions.UnivariateDistribution, X::AbstractArray) in Distributions.jl.
Methods
Base.convert(::Type{LogNormalBPL{T}}, d::LogNormalBPL)minimum(d::LogNormalBPL)maximum(d::LogNormalBPL)partype(d::LogNormalBPL)eltype(d::LogNormalBPL)mean(d::LogNormalBPL)median(d::LogNormalBPL)pdf(d::LogNormalBPL,x::Real)logpdf(d::LogNormalBPL,x::Real)cdf(d::LogNormalBPL,x::Real)ccdf(d::LogNormalBPL,x::Real)quantile(d::LogNormalBPL{S},x::T) where {S,T<:Real}quantile!(result::AbstractArray,d::LogNormalBPL{S},x::AbstractArray{T}) where {S,T<:Real}quantile(d::LogNormalBPL{T},x::AbstractArray{S})cquantile(d::LogNormalBPL{S},x::T) where {S,T<:Real}rand(rng::AbstractRNG, d::LogNormalBPL,s...)- Other methods from
Distributions.jlshould also work becauseLogNormalBPL <: AbstractIMF <: Distributions.ContinuousUnivariateDistribution. For example,rand!(rng::AbstractRNG, d::LogNormalBPL, x::AbstractArray).