Create a logarithmic Latin Hypercube Sampling distribution (with lhsdesign).
27 views (last 30 days)
Show older comments
Hi,
i want to get a logarithmic sample distribution with lhsdesign and fix boundaries. Heres my code:
num_samples = 40; % number of samples
num_parameters = 2; % number of parameters
variableBounds = [1e-14 1e-12; 1e-14 1e-12]; % defines the boundaries
lhsMatrix = lhsdesign(num_samples, num_parameters);
% Scale the LHS samples to the desired parameter ranges
params = zeros(num_samples, num_parameters);
for j = 1:num_parameters
params(:, j) = lhsMatrix(:, j) * (variableBounds(j, 2) - variableBounds(j, 1)) + variableBounds(j, 1);
end
scatter(params(:,1), params(:,2),'filled', 'MarkerFaceAlpha',0.3, 'SizeData',90,'MarkerFaceColor', 'blue');
xlabel('$Parameter 1$', 'Interpreter', 'latex');
ylabel('$Parameter 2$', 'Interpreter', 'latex');
title('Sample distribution');
% set(gca, 'XScale', 'log');
% set(gca, 'YScale', 'log');
grid on
If i create the lhsMatrix with lhsdesign, the samples will get distributed perfectly with no log axes.
What i desire is a proper sample distribution with log axes.
num_samples = 40; % number of samples
num_parameters = 2; % number of parameters
variableBounds = [1e-14 1e-12; 1e-14 1e-12]; % defines the boundaries
lhsMatrix = lhsdesign(num_samples, num_parameters);
% Scale the LHS samples to the desired parameter ranges
params = zeros(num_samples, num_parameters);
for j = 1:num_parameters
params(:, j) = lhsMatrix(:, j) * (variableBounds(j, 2) - variableBounds(j, 1)) + variableBounds(j, 1);
end
scatter(params(:,1), params(:,2),'filled', 'MarkerFaceAlpha',0.3, 'SizeData',90,'MarkerFaceColor', 'blue');
xlabel('$Parameter 1$', 'Interpreter', 'latex');
ylabel('$Parameter 2$', 'Interpreter', 'latex');
title('Sample distribution');
set(gca, 'XScale', 'log');
set(gca, 'YScale', 'log');
grid on
As you can see the distribution with log axes is really bad. So i need to create a lhsMatrix with log values to get a proper distribution on my log scales. Can someone help me out with this problem?
Thanks in advance :)
0 Comments
Accepted Answer
Harald
on 28 Jun 2023
Hi Lorenz,
I am not sure whether this is legitimate from the statistics point of view, but you could get a nice distribution by taking the log of the bounds and then the exponential of params. For better readability, you could use base 10 for both.
variableBounds = log10([1e-14 1e-12; 1e-14 1e-12]); % or log
%...
params = 10.^(params); % or exp
Best wishes,
Harald
More Answers (0)
See Also
Categories
Find more on Probability Distributions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!