function [f]=acceptance; %Acceptance.m: The input argument to this function is a function %This function uses acceptance-rejection to generate the distribution %P(x)=.75*(1-x^2) where -1<=x<=1 %Largest value the probability will reach is Pmax=.75 xtry=2*rand(1)-1; if (1-xtry^2)>=rand(1), f=xtry; else f=acceptance; end