function [m,v,p]=discretenorm(x,lambda) %outputs the value of the discrete normal distribution on the points x %together with the mean m and the variance v of the distribution. p=lambda(1)*x+lambda(2)*x.^2; p=exp(-p); p=p/sum(p); m=sum(x.*p); v=sum(p.*(x-m).^2);