function rnd=bellLike(a,b, nRnd, nSum) % Sample nRnd random numbers from a bell-like distribution % The higher nSum, the more similar to the Normal distribution % The support is [a, b] % The mean is (a+b)/2 option=0; switch option case 0 rnd=zeros(1,nRnd); for k=1:nSum rnd=rnd+rand(1,nRnd); end case 1 % Should be equivalent, but is not really! % Probably due to the way rand works. rnd=sum(rand(nSum,nRnd), 1 ) ; end rnd=rnd/nSum; % in [0,1] rnd=a+(b-a)*rnd; end