Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %LAB7
- a = input('a=');
- b = input('b=');
- N = input('N=');
- x=sort(unifrnd(a,b,N,1));
- n=1+(10/3)*log10(N);
- l=(max(x)-min(x))/n;
- [f,m]=hist(x,n);
- fr=f/N;
- y=min(x):l:max(x);
- i=1:n;
- r=[i;y(i);y(i+1);m;f;fr];
- fprintf('No| Class | Mark | Freq | R.Freq\n');
- fprintf('-------------------------------------------------\n');
- fprintf('%d | [%6.4f , %6.4f] | %6.4f | %6.4f | %6.4f \n',r);
- clf;
- hist(x,n);
- hold on;
- plot(m, f, 'r');
- %pct d
- aritm = mean(x);
- geom = geomean(x);
- harm = harmmean(x);
- fprintf('Arithmetic mean = %0.2f \nGeometric mean = %0.2f \nHarmonic mean = %0.2f\n', aritm, geom, harm);
- %median
- medi = median(x);
- fprintf('MEDIAN: %0.2f\n', medi);
- %mode
- mo=find(f==max(f));
- res=[y(mo);y(mo+1)];
- %quartiles
- quar=prctile(x,[25, 50, 75]);
- fprintf('Mode: %0.2f\n', res);
- fprintf('Quartiles: %0.2f\n', quar);
- %variance
- v=var(x);
- fprintf('Variance: %0.2f\n', v);
- %std deviation
- dev=std(x);
- fprintf('Standard deviation: %0.2f\n', dev);
- %moments
- m1=moment(x,1);
- m2=moment(x,2);
- m3=moment(x,3);
- m4=moment(x,4);
- fprintf('Centered Moment (x,1): %0.2f\n', m1);
- fprintf('Centered Moment (x,2): %0.2f\n', m2);
- fprintf('Centered Moment (x,3): %0.2f\n', m3);
- fprintf('Centered Moment (x,4): %0.2f\n', m4);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement