we have data that follows he lognormal distribution, knowing it's mean = 5.0163 and standard deviation = 1.0571 we want to generate and draw n (6000) sample within range (3:7.9) that follows the same distribution with monte-carlo method we have this code but it doesn't output samples in the desired range (all samples are smaller than the lower limit)
Data = [ 3 3 3 3 3.3 3.3 3.6 3.9 3.9 3.9 3.9 3.9 3.9 3.9 3.9 3.9 3.9 3.9 3.9 4.2 4.2 4.2 4.2 4.2 4.2 4.5 4.5 4.5 4.5 4.5 4.5 4.5 4.8 4.8 4.8 4.8 4.8 4.8 4.8 4.8 4.8 5.1 5.1 5.1 5.1 5.1 5.1 5.1 5.1 5.1 5.1 5.1 5.1 5.4 5.4 5.4 5.4 5.4 5.4 5.4 5.4 5.4 5.7 6 6 6 6 6 6 6 6 6.3 6.3 6.3 6.3 6.3 6.3 6.3 6.6 6.6 6.6 6.6 6.9 6.9 6.9 7.8];
%draw Lognormal Fit of the data
histfit(Data,[],'lognormal');
% lognormal curve parameters
LN = lognfit(Data);
m=LN(1);
s=LN(2);
% mean and stanard diviation of the associated normal dist.
mu=log(m^2/sqrt(s^2+m^2));
sigma=sqrt(log((s^2/m^2)+1));
%generate random numbers
for i = 1 : 100
X = lognrnd(mu,sigma)
if ((X>=3)&&(X<=7.9))
X;
end
end