Model Monte Carlo Simulation
    8 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
Hi, I want to use monte carlo simulation for my model uncertainty analysis. Model equation is y= (a x b x c) / d. For this equation a and b are measureable deterministic variables and change day by day. c and d are stochastic variables. c has uniform distribution interval of [25,35] and d has uniform distribuiton interval of [35,70].
5 day measurements are shown below.
day 1     a= 7  b= 8
day 2     a= 9  b= 12
day 3     a= 14  b= 15
day 4     a= 18  b= 19
day 5     a= 5  b= 4
How can ı draw histogram and calculate mean,standard deviation for output (y) by using 10 000 samples for each day. Thank you for your help.
0 Kommentare
Antworten (1)
  Parag
 am 28 Jan. 2025
        Hi, please see the below MATLAB code to draw histogram and calculate mean, standard deviation for output (y) by using 10 000 samples each day. 
% Deterministic variables for each day 
a_values = [8, 9, 7, 6, 5]; % a for day 1 to 5 
b_values = [8, 12, 15, 10, 4]; % b for day 1 to 5 
% Stochastic variable ranges 
c_min = 25; c_max = 35; % Uniform distribution for c 
d_min = 35; d_max = 70; % Uniform distribution for d 
% Number of Monte Carlo samples 
num_samples = 10000; 
% Initialize storage for results 
means = zeros(1, 5); % Mean of y for each day 
std_devs = zeros(1, 5); % Standard deviation of y for each day 
% Loop through each day 
for day = 1:5 
    % Get deterministic variables for the day 
    a = a_values(day); 
    b = b_values(day);  
    % Generate random samples for c and d 
    c = c_min + (c_max - c_min) * rand(num_samples, 1); 
    d = d_min + (d_max - d_min) * rand(num_samples, 1); 
    % Compute y for all samples 
    y = (a * b * c) ./ d; 
    % Compute mean and standard deviation of y 
    means(day) = mean(y); 
    std_devs(day) = std(y); 
    % Plot histogram of y 
    figure; 
    histogram(y, 50, 'Normalization', 'pdf'); % 50 bins, normalized as PDF 
    title(['Day ', num2str(day), ' Histogram of y']); 
    xlabel('y'); 
    ylabel('Probability Density'); 
end 
% Display mean and standard deviation for each day 
disp('Mean of y for each day:'); 
disp(means); 
disp('Standard deviation of y for each day:'); 
disp(std_devs); 
If you would like to know more about Monte Carlo Simulation, you can refer to following documentation: https://www.mathworks.com/discovery/monte-carlo-simulation.html 
0 Kommentare
Siehe auch
Kategorien
				Mehr zu Monte-Carlo finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

