You have some additional method definitions of maxwell
hanging around in addition to what you’ve posted. In fact, what you’ve posted simply doesn’t work (because 300::AbstractFloat
is an error):
julia> function maxwell(mass::AbstractFloat, temp=300::AbstractFloat)
kb = 1.380649E-23 # J/K
s = sqrt(kb * temp / mass)
return s * Distributions.Chi(3)
end
maxwell (generic function with 2 methods)
julia> d1 = maxwell(4e-26)
ERROR: TypeError: in typeassert, expected AbstractFloat, got a value of type Int64
Remove the unnecessary annotations (and restart Julia or use Revise.jl to remove the old method definitions) and you get differently-scaled Chi distributions like you expect:
julia> function maxwell(mass, temp=300)
kb = 1.380649E-23 # J/K
s = sqrt(kb * temp / mass)
return s * Distributions.Chi(3)
end
maxwell (generic function with 2 methods)
julia> d1 = maxwell(4e-26)
LocationScale{Float64, Continuous, Chi{Float64}}(
μ: 0.0
σ: 321.7897994032751
ρ: Chi{Float64}(ν=3.0)
)
julia> d2 = maxwell(5e-26)
LocationScale{Float64, Continuous, Chi{Float64}}(
μ: 0.0
σ: 287.81754637269773
ρ: Chi{Float64}(ν=3.0)
)