Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
figure()
x = data.root.datasets.poisson.x.read()
y = data.root.datasets.poisson.y.read()
yerr = data.root.datasets.poisson.yerr.read()
errorbar(x, y, yerr=yerr, fmt='o', label="Data")
x = linspace(-10, 10, 101)
f = vectorize(lambda x: 1 - exp(-.5 * x) if x >= 0 else 0.)
for s in [0., 0.5, 1., 1.5]:
if s == 0.:
plot(x, f(x), label="Unconvoluted")
else:
g = stats.norm(scale=s).pdf
plot(x, discrete_convolution(f, g, x),
label="sigma = %.2f m$^{-2}$" % s)
xlim(0, 5)
title("Effect of uncertainty on particle density")
xlabel("Charged particle density (m$^{-2}$)")
ylabel("Probability of one or more particles")
legend(loc='best')
savefig("plots/conv_poisson.pdf")