Hello,
Distributions.jl does not have an implementation of the Maxwell-Boltzmann distribution, but it does have the Chi distribution, which is a more general form of the Maxwell-Boltzmann case. I’m hoping to simply apply a transformation to the Chi distribution, but that is not working as I had hoped.
"""
Returns a Maxwell-Boltzmann distribution of velocity (m/s)
for particles of given mass (Kg) at a given temperature (K)
"""
function maxwell(mass::AbstractFloat, temp=300::AbstractFloat)
kb = 1.380649E-23 # J/K
s = sqrt(kb * temp / mass)
return s * Distributions.Chi(3)
end
This function does not seem to work. Compare what happens when I use my function vs scaling manually in the terminal:
julia> d1 = maxwell(4e-26)
Chi{Float64}(ν=3.0)
julia> d2 = maxwell(5e-26)
Chi{Float64}(ν=3.0)
julia> d3 = 3 * Distributions.Chi(3)
LocationScale{Int64, Continuous, Chi{Float64}}(
μ: 0
σ: 3
ρ: Chi{Float64}(ν=3.0)
)
julia> d4 = 4 * Distributions.Chi(3)
LocationScale{Int64, Continuous, Chi{Float64}}(
μ: 0
σ: 4
ρ: Chi{Float64}(ν=3.0)
)
If I plot the pdfs of d1 and d2, the curves are superimposed - they are identical. But if I plot the pdfs of d3 and d4, they are shifted as expected. I don’t understand where the discrepancy arises.
Any help with this issue would be appreciated,
Thanks
Note: A previous post discussed the relationship between Maxwell-Boltzmann and Chi distributions, and the use of LocationScale.