m=1/sqrt(2*%pi)
function y=f(x)
    y=m*exp(-x*x/2)
endfunction
X=zeros(1,10000)
for k=1:10000
x=-5+10*rand()
y=m*rand()
while y>f(x)
    x=-5+10*rand()
    y=m*rand()
end
X(1,k)=x
end
clf
classes=linspace(-5,5,21)
histplot(classes,X)
x=linspace(-5,5,101)
plot(x,f)
