Latin hypercube sample from beta distribution
26 次查看(过去 30 天)
显示 更早的评论
I need to extract 10000 samples from a beta distribution with the help of Latin hypercube. the "lhsnorm" command only helps in case of a normal distribution. I also could not find much under "lhsdesign". How should I do this? Thank you everyone in advance.
0 个评论
回答(1 个)
Aditya
2025-2-3
Hi Eagle
To generate samples from a beta distribution using Latin Hypercube Sampling (LHS), you can use the lhsdesign function to generate samples from a uniform distribution and then transform these samples to follow a beta distribution. Here's a step-by-step guide on how to achieve this in MATLAB:
% Parameters for the beta distribution
a = 2; % Shape parameter alpha
b = 5; % Shape parameter beta
% Number of samples
numSamples = 10000;
% Generate Latin hypercube samples from a uniform distribution
uniformSamples = lhsdesign(numSamples, 1);
% Transform uniform samples to beta distribution using the inverse CDF
betaSamples = betainv(uniformSamples, a, b);
% Plot the histogram of the generated beta samples
figure;
histogram(betaSamples, 50, 'Normalization', 'pdf');
hold on;
% Plot the theoretical beta distribution for comparison
x = linspace(0, 1, 100);
y = betapdf(x, a, b);
plot(x, y, 'r-', 'LineWidth', 2);
xlabel('Value');
ylabel('Probability Density');
title('Beta Distribution Samples using Latin Hypercube Sampling');
legend('Sampled Data', 'Theoretical Beta PDF');
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Industrial Statistics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!