Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% Ex.01
- clear all; close all; clc; rng('default');
- N = 9999;
- MEAN10 = zeros(N,1);
- MEAN100 = zeros(N,1);
- for i=1:N
- MEAN10(i) = mean(sqrt(2) * randn(10,1) + 4);
- MEAN100(i) = mean(sqrt(2) * randn(100,1) + 4);
- end
- subplot(1,2,1); hist(MEAN10, 30);
- title('MEAN 10');
- subplot(1,2,2); hist(MEAN100, 30);
- title('MEAN 100');
- %% Ex.02
- clear all; close all; clc;
- N = 9999;
- chi = zeros(N,1);
- tStud = zeros(N,1);
- for i=1:N
- sample = sqrt(2) * randn(10,1) + 4;
- MEAN = mean(sample);
- s = 0;
- for j = 1:10
- s = s + (1/9)*((sample(j)-MEAN)^2);
- end
- chi(i) = (9*s)/2;
- tStud(i) = ((MEAN - 4)/sqrt(s))*sqrt(9);
- end
- x_axis_chi = 0:0.1:50;
- x_axis_t = -4:0.1:4;
- subplot(2,2,1); hist(chi, 50);
- subplot(2,2,2); plot(x_axis_chi,chi2pdf(x_axis_chi,9));
- subplot(2,2,3); hist(tStud, 50);
- subplot(2,2,4); plot(x_axis_t,tpdf(x_axis_t,9));
- %% Ex.03
- close all; clear all; clc; rng('default');
- X = sqrt(2)*randn(10,1) + 4;
- % A
- sigma_A = sqrt(2);
- alfa_A = 0.05;
- mean_A = mean(X);
- n_A = length(X);
- norm_inv_A = norminv([alfa_A/2 1-(alfa_A/2)]);
- norm_range_A = mean_A + (norm_inv_A .* (sigma_A/sqrt(n_A)));
- % B
- sigma_B = sqrt(2);
- alfa_B = 0.1;
- mean_B = mean(X);
- n_B = length(X);
- norm_inv_B = norminv([alfa_B/2 1-(alfa_B/2)]);
- norm_range_B = mean_B + (norm_inv_B .* (sigma_B/sqrt(n_B)));
- % C
- sigma_C = std(X);
- alfa_C = 0.05;
- n_C = length(X);
- mean_C = mean(X);
- norm_inv_C = tinv([1-alfa_C/2 alfa_C/2], 9);
- norm_range_C = mean_C + (norm_inv_C .* (sigma_C/sqrt(n_C)));
- norm_range_C = sort(norm_range_C,'ascend');
- %% Ex.04
- clear all; close all; clc; rng('default');
- X = sqrt(2)*randn(10,1) + 4;
- MEAN = mean(X);
- sigma = std(X);
- alfa = 0.05;
- freedom = length(X) - 1;
- chi2_range = chi2inv([1-(alfa/2) alfa/2], freedom);
- chi2_range = sqrt((freedom * sigma^2)./chi2_range);
- %% Ex.05
- close all; clear all; clc;
- X = [15.43, 16.92, 14.43, 12.94, 15.92, 17.42, 18.91, 16.92, 14.93, 14.49, 15.92, 15.43];
- X = sort(X, 'ascend');
- MEAN = mean(X); SIGMA = std(X);
- N = length(X);
- SREDNI_PRZYROST = SIGMA/MEAN;
- ROZSTEP = max(X) - min(X);
- alfa = 0.05;
- norm_inv = norminv([alfa/2 1-(alfa/2)]);
- norm_range = MEAN + norm_inv.*SIGMA/sqrt(length(X));
- M = 1000;
- values = zeros(M,1);
- for i=1:M
- index = randi([1 12],1,1);
- disp(index);
- values(i) = X(index);
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement