I change the npdensity(z) of mcreel to work with superior and inferior limits to solve my problem. I want to plot the normal curve to show examples of hypothesis testing.
using KernelDensity, Plots, Distributions
function npdensity(z,inferior,superior)
n = size(z,2)
p = zeros(n)
for i = 1:n
x = z[:,i]
y = kde(x)
q05 = quantile(x,0.05)
Plots.plot(range(minimum(x), stop=inferior, length=100),z->pdf(y,z), color=:red, fill=(0,0.5,:red), label="-Zc")
q95 = quantile(x,0.95)
Plots.plot!(range(inferior, stop=superior, length=100),z->pdf(y,z), color=:green, fill=(0,0.5,:green),label="Região de Aceitação")
Plots.plot!(range(superior, stop=maximum(x), length=100),z->pdf(y,z), color = :red, fill=(0,0.5,:red),label="Zc")
m = mean(x)
Plots.plot!([m,m],[0,pdf(y,m)],color=:blue, label="média")
m = median(x)
if i == 1
p = Plots.plot!([m,m],[0,pdf(y,m)],color=:black, label="mediana")
else
p = [p, Plots.plot!([m,m],[0,pdf(y,m)],color=:black, label="mediana")]
end
end
return p
end
parafusos = rand( Normal( 0 , 1 ),1000000)
npdensity(parafusos,-1.96,1.96)