How to have uniform distribution drop to zero at edges?

Viewed 58
using Plots
using Distributions
gr()

plot(Uniform(0,1))
xlabel!("velocity")
ylabel!("probability density")
xlims!(-0.5, 1.5)
ylims!(0, 1.5)

I am trying to plot a uniform distribution with area under the curve = 1. I would like the edges of the curve to drop to zero so the curve looks more like a box and less like a straight line. Any suggestions?

1 Answers

Probably the easiest way to do this is to explicitly plot the actual pdf of the distribution over some relevant range of x values. For example:

using Plots, Distributions

x = -0.5:0.001:1.5
plot(x, pdf.(Uniform(0,1), x), label="distribution")
xlabel!("velocity")
ylabel!("probability density")
xlims!(-0.5, 1.5)
ylims!(0, 1.5)

yields

uniform pdf from 0 to 1

Related