Latin hypercube sample from beta distribution

26 views (last 30 days)
Eagle Lee
Eagle Lee on 21 Jan 2017
Answered: Aditya on 3 Feb 2025
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.

Answers (1)

Aditya
Aditya on 3 Feb 2025
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');

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!