I have some set of output data for some mathematical formula for a range of different input data , I need to plot uncertainty histogram of Monte Carlo for this set using MATLAB
I tried several codes (giving that number of the data set is 26500 population)
1st one
clc;
%data = load('w_linear.txt'); % Assuming w_linear.txt contains one column of data
num_bins = 350;
% Create a histogram of the w values
histogram(w_linear, num_bins, 'Normalization', 'probability');
% Add title and labels
title('Monte Carlo Distribution of w');
xlabel('w');
ylabel('Probability');
% Show grid
grid on;
2nd one
clc;
%data = load('w_linear.txt'); % Assuming W.txt contains one column of data
population_size = numel(w_linear);
sample_size = 1000;
sampling_interval = ceil(population_size / sample_size);
starting_point = randi(sampling_interval);
sample_indices = starting_point:sampling_interval:population_size;
sample = w_linear(sample_indices);
histogram(sample);
3rd one
clc;
%data = load('w_linear.txt'); % Assuming W.txt contains one column of data
num_bins = 350;
% Take a random sample of the data for visualization (optional)
sample_size = 1000; % Choose a sample size that is manageable for visualization
sample_indices = randperm(length(w_linear), sample_size);
w_sample = w_linear(sample_indices);
% Create a histogram of the sampled w values
histogram(w_sample, num_bins, 'Normalization', 'probability');
% Add title and labels
title('Monte Carlo Distribution');
xlabel('Value');
ylabel('Probability');
% Show grid
grid on;
4th one
%data = load('w_linear.txt'); % Assuming W.txt contains one column of data
% Number of simulations
num_simulations = size(w_linear, 2);
% Plot histogram of each simulation
hold on;
for i = 1:num_simulations
histogram(w_linear(:, i), 'Normalization', 'probability', 'DisplayStyle', 'stairs');
end
hold off;
xlabel('Metric of Interest');
ylabel('Probability');
title('Monte Carlo Histogram');
I am confused which one of the previous approach is better