Plotting two distributions on same plot

I am trying to plot two probability distributions onto the same plot. One is a uniform distribution with area under the curve = 1 and the other is a chi distribution (or to be more specific, a Maxwellian) with three degrees of freedom with area under the curve = 1. Here is my code so far:

using Plots, Distributions

v = -0.5:0.001:1.5
f_s0 = pdf.(Uniform(0,1), v) # uniform distribution with area 1
F_s = pdf.(Chi(3), v)  # chi distribution with area 1

plot(v, f_s0, label="f_s0")
plot!(v, F_s, linecolor = :orange, linestyle = :dash, label="F_s (Maxwellian)")
ylabel!("probability density")
xlims!(-0.5, 1.5)
ylims!(0, 1.5)

When I run this, I get

DomainError with -0.5:
log will only return a complex result if called with a complex argument. Try log(Complex(x)).

Any suggestions?

1 Like

Looks like a bug. See issue filed here and PR here

1 Like