rand vs. randn

			
				% rand vs. randn

				clear;
				clc;
				close all;

				n = 1000; % count
				m = 100; % bins

				% "uniformly distributed" random numbers
				xu = rand(n,1); % nx1 array
				[N, XU] = hist(xu, m); % N = bin counts, XU = bin centers
				subplot(2,1,1);
				bar(XU, N, 'w');
				title('uniform');
				xlabel('bin');
				ylabel('count');

				% "normally distributed" random numbers
				xn = randn(n,1); 
				[N, XN] = hist(xn, m);
				subplot(2,1,2);
				bar(XN, N, 'b');
				title('normal');
				xlabel('bin');
				ylabel('count');
			
		
© 2018 Copyright. For individual use only. No liability is accepted for any consequences of using information on Testips.com.