호그와트

어느 통계학자의 기록 with 캐럿 my codes (2)

영웅*^%&$ 2024. 6. 23. 15:41
728x90
%% Part (a): Finding the Standard Deviation
% X is the weight of coffee jars in gram
% X ~ N(100.5, o)
% p(X<100) = 0.03;
% Given values
mean_weight_a = 100.5;
rejection_probability_a = 0.03;
cutoff_weight_a = 100;
% Find the z-score corresponding to the bottom 3% of the normal distribution
z_score_rejection_a = norminv(rejection_probability_a);
% Solve for the standard deviation
std_dev_a = (cutoff_weight_a - mean_weight_a) / z_score_rejection_a;
%% Part (b): Proportion of Jars Weighing Between 100g and 100.8g
% Given values
upper_limit_weight_b = 100.8;
% Calculate the z-scores for 100g and 100.8g
z_score_lower_b = (cutoff_weight_a - mean_weight_a) / std_dev_a;
z_score_upper_b = (upper_limit_weight_b - mean_weight_a) / std_dev_a;
% Proportion of jars weighing between 100g and 100.8g
proportion_between_b = normcdf(z_score_upper_b) - normcdf(z_score_lower_b);
% proportion_between_b = normspec([100, 100.8], mean_weight_a, std_dev_a);
%% Part (c): find the probability for the avergage of 5 random picks between 100g and 100.8g
% P(100<mean(X5)<100.8)
% Given values
mean_weight_a = 100.5;
std_dev_b = std_dev_a / sqrt(5);
% getting the proportion for five picks between 100g and 100.8g
proportion_between_five = normcdf(100.8, mean_weight_a, std_dev_b) - normcdf(100, mean_weight_a, std_dev_b);
%% Part (d): Adjusting the Mean Value
% Given values
cutoff_weight_d = 100;
top_99_percentile_d = 0.99;
% Find the z-score for the top 99%
z_score_99_percentile_d = norminv(top_99_percentile_d);
% Calculate the new mean for part (d)
new_mean_d = cutoff_weight_d + (z_score_99_percentile_d * std_dev_a);
% The mean value should be set above new_mean_d
%% Part (e): Adjusting the Mean Value
% Given values
% mean_weight_a = 100.5;
cutoff_weight_d = 100;
top_99_percentile_d = 0.99;
% Find the z-score for the top 99%
z_score_99_percentile_d = norminv(top_99_percentile_d);
% Calculate the new dev for part (e)
new_dev_d = (cutoff_weight_d - mean_weight_a) / z_score_99_percentile_d;
728x90

'호그와트' 카테고리의 다른 글

tryhackme W1seGuy fun  (0) 2024.06.24
happy monday  (0) 2024.06.24
어느 통계학자의 기록 with 캐럿 my codes (1)  (0) 2024.06.23
AI가 졸린지 아닌지 판별할 수 있는 건에 관하여  (0) 2024.06.23
Where is caesar ?  (0) 2024.06.12